PedroGeoGISdev
  • Home
  • Linux OS
    • Linux: concepts
    • Linux: basic concepts
    • Linux: Bash
    • Linux: su and sudo
    • Linux: pipes
    • Linux: File System
    • Linux: Virtual Machines

    • Linux: distros
    • Linux Distros: Ubuntu
    • Linux Distros: Mint
    • Linux Distros: Debian
    • Linux Distros: openSuse
    • Linux Distros: Manjaro
    • Linux Distros: Red Hat Enterprise

    • Linux: laboratories
    • Linux Lab#LI01-1: Choose Linux
    • Linux Lab#LI01-2: Install at least three distributions
    • Linux Lab#LI01-3: Adjust user permissions
    • Linux Lab#LI02-1: Export env user with grep and pipe
    • Linux Lab#LI03-1: Manage users and groups
    • Linux Lab#LI03-2: Manage files
    • Linux Lab#LI03-3: Manage software
    • Linux Lab#LI03-4: Manage hardware
    • Linux Lab#LI04-1: Bash scripting, qtool
    • Linux Lab#LI04-2: Bash scripts as terminal tool
    • Linux Lab#LI04-3: Distribute the terminal app

    • Linux readings
    • Linux Resources
  • DevOps
    • What is DevOps
    • DevOps: Introduction
    • DevOps: Agile and Microservices
    • Infrastructure as code (IaC)
    • Immutable Infrastructure
    • Software Lifecycle

    • Documentation
    • How to document: Quarto and Obsidian

    • Network protocols
    • Network: Basics
    • Network: Client-server
    • Network Protocols
    • Network: DNS
    • Network: API Rest
    • Network: gRPC
    • Network: Websocket
    • Network: SMTP
    • Network: Ping
    • Network: UDP
    • Network: webhook
    • Network: SOAP
    • Network: graphQL

    • Version Control
    • Git
    • GitHub
    • Idea and GitHub 2023
    • Git and GitHub 2023 CLI

    • IDEs
    • IDE: Visual Code
    • IDE: IntellJIdea

    • DevOps tools
    • Amazon Web Services AWS
    • Docker
    • Jenkins pipelines
    • Kubernetes k8s
    • Digital Ocean
    • Nagios
    • Ansible

    • DevOps Laboratories
    • Lab 1: chat App
    • Lab 2: Spring Boot AWS AEB manually
    • Lab 3: Spring Boot and AWS S3 publisher
    • Lab 4: Spring Boot Docker/Jenkins
    • Lab 5: k8s on Digital Ocean
    • Lab 6: Spring Boot AWS codecommit

    • DevOps readings
    • DevOps Resources
  • MarkUp
    • MarkUp Languages
    • Introduction Markup
    • HTML Markup
    • Markdown Markup
    • Markdown and HTML working together, good idea?

    • Quarto Markdown
    • Quarto Markdown: basics
    • Quarto Markdown: creating
    • Quarto Markdown: publishing
    • Quarto Markdown: code & data
    • Quarto Markdown: api rest call
    • Quarto Markdown: OJS Cells
    • Quarto Markdown: cheat-sheet

    • Styling: CSS
    • Cascade Style Sheet
    • Cascade Style Sheet: Box Model and Containers
    • CSS: W3.css

    • MarkUp Languages Laboratories
    • Lab#MD01-1: Create and publish by Quarto

    • MarkUp Languages readings
    • MarkUp Languages Resources
  • Java SE
    • What is Java SE
    • Java Standard Edition: Basics
    • Java Standard Edition: Principles
    • Java MOOC Helsinki
    • Java MOOC Helsinki Syllabus

    • Java Create Project
    • Java SE: Maven
    • Java SE: Create Maven Project
    • Java SE: Project push GitHub
    • Java SE: JUnit and TDD

    • Java Concepts
    • Java SE: Class and Objects
    • Java SE: Scope
    • Java SE: static modifier
    • Java SE: Coupling and DDD
    • Java SE: Packages
    • Java SE: Abstract/Interface
    • Java SE: Java 8

    • Java Principles
    • Java SE: Encapsulation
    • Java SE: Abstraction
    • Java SE: Inherence
    • Java SE: Polymorphism

    • Java Design Patterns
    • Java Patterns: UML
    • Java Patterns: Types
    • Singleton
    • Factory
    • Abstract Factory
    • Builder
    • Facade
    • Bridge
    • Decorator
    • Composite
    • Observer
    • Strategy
    • State
    • Commander

    • Java SE Laboratories
    • Lab#SE00-1: Maven Person
    • Lab#SE00-2: Maven Clinic
    • Lab#SE00-3: Library Model
    • Lab#SE00-4: Abstract/Interface Human
    • Lab#SE01-1: Maven/Gradle Person and Account
    • Lab#SE01-2: Maven/Gradle Person and Account stored in JSON
    • Lab#SE02-1: Movie/Review, Model
    • Lab#SE02-2: Movie/Review, CRUD Operations
    • Lab#SE02-3: Movie/Review, factory
    • Lab#SE02-4: Movie/Review, interactivity and coupling
    • Lab#SE02-5: Movie/Review, simulate interactivity by console
    • Lab#SE03-1: Library/Book, Core-Model
    • Lab#SE03-2: Library/Book, Sprint Zero
    • Lab#SE03-3: Library/Book, Expand Model
    • Lab#SE04-1: healthyFood Restaurant, Core Model

    • Java SE readings
    • Java SE Resources
  • Python
    • Python Basics
    • Python: Basic Concepts
    • Python: Numbers
    • Python: Strings
    • Python: Conditionals
    • Python: Lists and Loops
    • Python: Nested Loops
    • Python: Tuples
    • Python: Sets
    • Python: Dictionaries
    • Python: Functions
    • Python: Higher-order Functions
    • Python: Variable Scope
    • Python: Variable Assigment
    • Python: None keyword in Python
    • Python: Object Oriented Programming (OOP)
    • Python: Inheritance and Polymorphism
    • Python: Encapsulation
    • Python: Abstraction
    • Python: Cheat-Sheets
  • JavaScript
    • JavaScript Basics
    • JavaScript: Fundamentals
    • JavaScript: Data Types
    • JavaScript: Variables
    • JavaScript: Operators
    • JavaScript: Conditionals
    • JavaScript: Loops
    • JavaScript: Functions
    • JavaScript: Arrays
    • JavaScript: Objects

    • React Framework

    • ReactJS: Principles
    • React JS: Introduction
    • React JS: render virtual DOM
    • React JS: Create a React project
    • React JS: Components
    • React JS: JSX
    • React JS: props and state

    • JavaScript: web scripting
    • JavaScript: basics
    • JavaScript: functions
    • JavaScript: objects
    • JavaScript: variables
    • JavaScript: flux control

    • ES6: ECMAScript 6
    • React JS ES6: arrow functions
    • React JS ES6: import modules
    • React JS ES6: array, data and key
    • React JS ES6: destructuring
    • React JS ES6: spread operator

    • ReacJS 18: Hooks
    • React JS: Rules of Hooks
    • ReactJS: useState
    • React JS: useReducer
    • React JS: useRef
    • React JS: useEffect
    • React JS: useContext
    • ReactJS: useMemo
    • ReactJS: custom hooks

    • ReactJS: Designing an App
    • React JS App: async
    • React JS App: events
    • React JS App: router
    • React JS App: conditional render
    • React JS App: styling

    • React JS: Laboratories
    • Lab#RE01-1: API Rest Axios
    • Lab#RE02-1: Router & Hooks
    • Lab#RE03-1: to-do app
    • Lab#RE03-2: HighCharts
    • Lab#RE03-3: API Rest Mono
    • Lab#RE03-4: API Rest Domains
    • Lab#RE03-5: data management
    • Lab#RE04-1: todo & server
    • Lab#RE04-2: Spring Boot & ReactJS
    • Lab#RE05-1: chat & websockets
    • Lab#RE05-2: chat: backend
    • Lab#RE05-3: chat & AWS
    • Lab#RE05-4: chat: test ws AWS
    • Lab#RE05-5: chat & front
    • Lab#RE05-6: chat & ws: front
    • Lab#RE06-1: healthyFood Restaurant
    • Lab#RE06-1-PR: create a pull request
    • Lab#RE07-1: traffic lights simulation

    • React JS readings
    • ReactJS Resources
  • Backend
    • Spring Legacy
    • Spring Framework
    • Spring MVC
    • Springs Servlets

    • Spring Boot Basics
    • Spring Boot: fundamentals
    • Spring Boot: create a Project
    • Spring Boot: H2 DB and Thymeleaf
    • Spring Boot: cycle

    • Spring Boot Concepts
    • Spring Boot: Dependency Injection
    • Spring Boot: Annotations
    • Spring Boot: Controller
    • Spring Boot: View
    • Spring Boot: Thymeleaf
    • Spring Boot: Vaadin Flow
    • Spring Boot: Vaadin Hilla
    • Spring Boot: Model
    • Spring Boot: Rest
    • Spring Boot: Data & DB
    • Spring Boot: JPA & DI
    • Spring Boot: JPA Mappings
    • Spring Boot: JPA Relationships
    • Spring Boot: JPA Queries
    • Spring Boot: JPA Inherence
    • Spring Boot: Scaling

    • Spring Boot Laboratories
    • Lab#SB00-1: Library UML
    • Lab#SB00-2: CRUD User
    • Lab#SB00-3: LibraryManagement
    • Lab#SB00-4: API Rest
    • Lab#SB00-5: Rest & JPA-H2
    • Lab#SB00-6: Rest & MongoDB
    • Lab#SB00-7: Styling
    • Lab#SB01-1: DataBase
    • Lab#SB02-1: JPA Relationships
    • Lab#SB03-1: APIs & cloud
    • Lab#SB04-1: JPA Inherence
    • Lab#SB05-1: API Rest
    • Lab#SB06-1: employeeCourse
    • Lab#SB07-1: monitor Book
    • Lab#SB08-1: Restaurant UML
    • Lab#SB08-2: Vaadin
    • Lab#SB08-3: H2 and API Rest
    • Lab#SB08-4: JPA
    • Lab#SB08-5: Test API Rest
    • Lab#SB09-1: SpringIO Conference

    • Spring Boot readings
    • Spring Boot Resources
  • Learning
    • Vocabulary
    • General Vocabulary
    • SCRUM Vocabulary
    • DevOps Vocabulary
    • Java SE Vocabulay
    • Spring Boot Vocabulary
    • DataBase Vocabulary
    • ReactJS Vocabulary
    • Web Vocabulary

    • Learning
    • Useful Questions
    • Learning: tips
    • Writing
    • Taking Notes
    • Comments
    • Document
    • Auto-Evaluate

    • Books & Articles
    • Books
    • Articles

    • What is SCRUM
    • SCRUM Agile Methodology
    • Agile Manifesto & Values
    • SCRUM Guide

    • Scrum Steps
    • Meetings, Impediments and Iterations
    • User stories, Tasks and Habits
    • Delivering Value & Communication
    • ScrumMaster, how it works
    • Mindset, the key to everything
    • Product Owner, how it works
    • Managing Time & Mind
    • Team & the Specialist
    • Albertus’ Dilemma
    • Before SCRUM
    • Team Dynamics
    • Emotions and Thoughts
    • Decision Making and Intuition
    • Beyond SCRUM
    • Balances, atmosphere and tools

    • Resources
    • SCRUM Resources
  • QGIS
    • QGIS basics
    • QGIS: basic concepts

    • QGIS laboratories
    • QGIS Laboratory 1: Introduction to Open Source GIS
  • ArcGIS Pro
    • ArcGIS Pro basics
    • ArcGIS Pro: basic concepts

    • ArcGIS Pro laboratories
    • ArcGIS Pro Laboratory 1: Getting Started
  • Bookmarks
    • Online Resources
    • Online Resources
  • About
    • About me and this site
    • About me
    • About this site
    • About images credit
  • Maps
  • Featured Projects
    • ✈️ Flight tracker
    • 🧑 People tracker
    • 🚗 Renting Car
    • Email
    • GitHub
    • LinkedIn
  1. JavaScript Basics
  2. JavaScript: Objects
  • JavaScript

  • JavaScript Basics
    • JavaScript: Fundamentals
    • JavaScript: Data Types
    • JavaScript: Variables
    • JavaScript: Operators
    • JavaScript: Conditionals
    • JavaScript: Loops
    • JavaScript: Functions
    • JavaScript: Arrays
    • JavaScript: Objects

  • React Framework

  • ReactJS: Principles
    • React JS: Introduction
    • React JS: render virtual DOM
    • React JS: Create a React project
    • React JS: Components
    • React JS: JSX
    • React JS: props and state

  • JavaScript: web scripting
    • JavaScript: basics
    • JavaScript: functions
    • JavaScript: objects
    • JavaScript: variables
    • JavaScript: flux control

  • ES6: ECMAScript 6
    • React JS ES6: arrow functions
    • React JS ES6: import modules
    • React JS ES6: array, data and key
    • React JS ES6: destructuring
    • React JS ES6: spread operator

  • ReacJS 18: Hooks
    • React JS: Rules of Hooks
    • ReactJS: useState
    • React JS: useReducer
    • React JS: useRef
    • React JS: useEffect
    • React JS: useContext
    • ReactJS: useMemo
    • ReactJS: custom hooks

  • ReactJS: Designing an App
    • React JS App: async
    • React JS App: events
    • React JS App: router
    • React JS App: conditional render
    • React JS App: styling

  • React JS: Laboratories
    • Lab#RE01-1: API Rest Axios

    • Lab#RE02-1: Router & Hooks

    • Lab#RE03-1: to-do app
    • Lab#RE03-2: HighCharts
    • Lab#RE03-3: API Rest Mono
    • Lab#RE03-4: API Rest Domains
    • Lab#RE03-5: data management

    • Lab#RE04-1: todo & server
    • Lab#RE04-2: Spring Boot & ReactJS

    • Lab#RE05-1: chat & websockets
    • Lab#RE05-2: chat: backend
    • Lab#RE05-3: chat & AWS
    • Lab#RE05-4: chat: test ws AWS
    • Lab#RE05-5: chat & front
    • Lab#RE05-6: chat & ws: front

    • Lab#RE06-1: healthyFood Restaurant
    • Lab#RE06-1-PR: create a pull request

    • Lab#RE07-1: traffic lights simulation

  • React JS readings
    • ReactJS Resources

On this page

  • 1 Overview
  • 2 Creating Objects
    • 2.1 Object Literal Syntax
    • 2.2 Object Constructor Syntax
  • 3 Literals and Properties
  • 4 Accessing Properties
    • 4.1 Dot Notation
    • 4.2 Adding Properties
    • 4.3 Removing Properties
    • 4.4 Multiword Property Names
    • 4.5 Trailing Comma
  • 5 Square Bracket Notation
    • 5.1 Dynamic Property Access
  • 6 Computed Properties
    • 6.1 Complex Expressions
  • 7 Property Value Shorthand
    • 7.1 Shorthand
  • 8 Property Names Limitations
    • 8.1 Special Property: proto
  • 9 Property Existence Test
    • 9.1 The “in” Operator
    • 9.2 Why Use “in”?
  • 10 The “for…in” Loop
    • 10.1 Example
  • 11 Object References and Copying
    • 11.1 Comparison by Reference
  • 12 Cloning Objects
    • 12.1 Manual Cloning
    • 12.2 Object.assign
    • 12.3 Simple Cloning
  • 13 Nested Objects
    • 13.1 Deep Cloning
  • 14 Examples
    • 14.1 Example 1: User Object
    • 14.2 Example 2: Modifying Properties
    • 14.3 Example 3: Methods in Objects
    • 14.4 Example 4: this Keyword
    • 14.5 Example 5: Iterating Over Properties
    • 14.6 Example 6: Object as Function Parameter
  • 15 Summary
  • Edit this page
  • View source
  • Report an issue
  1. JavaScript Basics
  2. JavaScript: Objects

JavaScript: Objects

JavaScript Objects

javascript
objects
data-structures
JavaScript Objects - Creating, Accessing, and Manipulating Objects
Author

Pedro GeoGIS

Published

Monday, January 13, 2025

Modified

Monday, October 13, 2025

1 Overview

📘 Objects

Objects are used to store keyed collections of various data and more complex entities. Unlike primitive types that contain only a single value, objects can store multiple values as properties. An object is a collection of key-value pairs where keys are strings (or Symbols) and values can be of any type. Objects are fundamental to JavaScript and penetrate almost every aspect of the language.


2 Creating Objects

An object can be created with curly brackets {...} with an optional list of properties.

2.1 Object Literal Syntax

let user = {};  // empty object

2.2 Object Constructor Syntax

let user = new Object();  // empty object

Recommendation: Use object literal syntax {} as it’s more concise and commonly used.


3 Literals and Properties

We can immediately put some properties into {...} as “key: value” pairs:

let user = {
  name: "John",    // by key "name" store value "John"
  age: 30          // by key "age" store value 30
};

A property has a key (also known as “name” or “identifier”) before the colon : and a value to the right of it.


4 Accessing Properties

4.1 Dot Notation

Property values are accessible using the dot notation:

let user = {
  name: "John",
  age: 30
};

alert(user.name);  // John
alert(user.age);   // 30

4.2 Adding Properties

user.isAdmin = true;

4.3 Removing Properties

To remove a property, use the delete operator:

delete user.age;

4.4 Multiword Property Names

We can use multiword property names, but they must be quoted:

let user = {
  name: "John",
  age: 30,
  "likes birds": true  // multiword property name must be quoted
};

4.5 Trailing Comma

The last property in the list may end with a comma:

let user = {
  name: "John",
  age: 30,  // trailing comma
};

This makes it easier to add/remove/move around properties.


5 Square Bracket Notation

For multiword properties, the dot access doesn’t work:

// This would give a syntax error
user.likes birds = true

Use square bracket notation instead:

let user = {};

// set
user["likes birds"] = true;

// get
alert(user["likes birds"]);  // true

// delete
delete user["likes birds"];

5.1 Dynamic Property Access

Square brackets provide a way to obtain the property name from a variable:

let user = {
  name: "John",
  age: 30
};

let key = prompt("What do you want to know about the user?", "name");

// access by variable
alert(user[key]);  // John (if enter "name")

The dot notation cannot be used this way:

let key = "name";
alert(user.key);  // undefined (looks for property named "key")

6 Computed Properties

We can use square brackets in an object literal when creating an object. That’s called computed properties.

let fruit = prompt("Which fruit to buy?", "apple");

let bag = {
  [fruit]: 5,  // the name of the property is taken from the variable fruit
};

alert(bag.apple);  // 5 if fruit="apple"

This is the same as:

let fruit = prompt("Which fruit to buy?", "apple");
let bag = {};
bag[fruit] = 5;

6.1 Complex Expressions

let fruit = 'apple';
let bag = {
  [fruit + 'Computers']: 5  // bag.appleComputers = 5
};

7 Property Value Shorthand

In real code, we often use existing variables as values for property names:

function makeUser(name, age) {
  return {
    name: name,
    age: age,
  };
}

let user = makeUser("John", 30);
alert(user.name);  // John

7.1 Shorthand

When property name and variable name are the same, we can use property value shorthand:

function makeUser(name, age) {
  return {
    name,  // same as name: name
    age,   // same as age: age
  };
}

We can use both normal properties and shorthands in the same object:

let user = {
  name,      // same as name:name
  age: 30
};

8 Property Names Limitations

A variable cannot have a name equal to one of the language-reserved words like “for”, “let”, “return”, etc.

But for an object property, there’s no such restriction:

let obj = {
  for: 1,
  let: 2,
  return: 3
};

alert(obj.for + obj.let + obj.return);  // 6

8.1 Special Property: proto

There’s a minor gotcha with a special property named __proto__. We can’t set it to a non-object value:

let obj = {};
obj.__proto__ = 5;  // assign a number
alert(obj.__proto__);  // [object Object] - didn't work as intended

9 Property Existence Test

A notable feature of objects in JavaScript is that it’s possible to access any property. There will be no error if the property doesn’t exist!

Reading a non-existing property just returns undefined:

let user = {};
alert(user.noSuchProperty === undefined);  // true means "no such property"

9.1 The “in” Operator

There’s a special operator "in" for checking property existence:

let user = { name: "John", age: 30 };

alert("age" in user);      // true, user.age exists
alert("blabla" in user);   // false, user.blabla doesn't exist

Note that on the left side of in there must be a property name (usually a quoted string).


9.2 Why Use “in”?

Usually, the comparison with undefined works fine. But there’s a special case when it fails:

let obj = {
  test: undefined
};

alert(obj.test);           // undefined, so property doesn't exist?
alert("test" in obj);      // true, the property does exist!

10 The “for…in” Loop

To walk over all keys of an object, use the for...in loop:

for (key in object) {
  // executes the body for each key among object properties
}

10.1 Example

let user = {
  name: "John",
  age: 30,
  isAdmin: true
};

for (let key in user) {
  // keys
  alert(key);         // name, age, isAdmin
  // values for the keys
  alert(user[key]);   // John, 30, true
}

11 Object References and Copying

One of the fundamental differences between objects and primitives is that objects are stored and copied “by reference”, whereas primitive values are copied “as a whole value”.

let message = "Hello!";
let phrase = message;  // copied by value

With objects:

let user = { name: "John" };
let admin = user;  // copy the reference

admin.name = 'Pete';  // changed by the "admin" reference
alert(user.name);     // 'Pete', changes are seen from the "user" reference

11.1 Comparison by Reference

Two objects are equal only if they are the same object:

let a = {};
let b = a;  // copy the reference

alert(a == b);   // true, both variables reference the same object
alert(a === b);  // true

But two independent objects are not equal:

let a = {};
let b = {};  // two independent objects

alert(a == b);  // false

12 Cloning Objects

12.1 Manual Cloning

let user = {
  name: "John",
  age: 30
};

let clone = {};  // the new empty object

// let's copy all user properties into it
for (let key in user) {
  clone[key] = user[key];
}

// now clone is a fully independent object
clone.name = "Pete";
alert(user.name);  // still John in the original object

12.2 Object.assign

We can use Object.assign for cloning:

Object.assign(dest, ...sources)

Example:

let user = { name: "John" };

let permissions1 = { canView: true };
let permissions2 = { canEdit: true };

// copies all properties from permissions1 and permissions2 into user
Object.assign(user, permissions1, permissions2);

// now user = { name: "John", canView: true, canEdit: true }

12.3 Simple Cloning

let user = {
  name: "John",
  age: 30
};

let clone = Object.assign({}, user);

13 Nested Objects

Objects can contain other objects as properties:

let user = {
  name: "John",
  sizes: {
    height: 182,
    width: 50
  }
};

alert(user.sizes.height);  // 182

13.1 Deep Cloning

For nested objects, simple cloning doesn’t work:

let user = {
  name: "John",
  sizes: {
    height: 182,
    width: 50
  }
};

let clone = Object.assign({}, user);

alert(user.sizes === clone.sizes);  // true, same object

// user and clone share sizes
user.sizes.width = 60;
alert(clone.sizes.width);  // 60, changed from the other object

Use structuredClone for deep cloning:

let clone = structuredClone(user);

alert(user.sizes === clone.sizes);  // false, different objects

user.sizes.width = 60;
alert(clone.sizes.width);  // 50, not affected

14 Examples

14.1 Example 1: User Object

let user = {
  name: "John",
  age: 30,
  email: "john@example.com",
  isAdmin: false
};

console.log(user.name);   // John
console.log(user["age"]); // 30

14.2 Example 2: Modifying Properties

let user = {
  name: "John",
  age: 30
};

user.age = 31;
user.city = "New York";
delete user.age;

console.log(user);  // { name: "John", city: "New York" }

14.3 Example 3: Methods in Objects

let user = {
  name: "John",
  age: 30,
  sayHi: function() {
    alert("Hello!");
  }
};

user.sayHi();  // Hello!

// Method shorthand
let user2 = {
  name: "John",
  sayHi() {  // same as sayHi: function()
    alert("Hello!");
  }
};

14.4 Example 4: this Keyword

let user = {
  name: "John",
  age: 30,
  sayHi() {
    alert(this.name);  // "this" refers to the current object
  }
};

user.sayHi();  // John

14.5 Example 5: Iterating Over Properties

let user = {
  name: "John",
  age: 30,
  city: "New York"
};

for (let key in user) {
  console.log(`${key}: ${user[key]}`);
}
// Output:
// name: John
// age: 30
// city: New York

14.6 Example 6: Object as Function Parameter

function printUser(user) {
  console.log(`Name: ${user.name}`);
  console.log(`Age: ${user.age}`);
}

let user = {
  name: "Alice",
  age: 25
};

printUser(user);

15 Summary

  • Objects are collections of key-value pairs
  • Create objects with {} or new Object()
  • Access properties with dot notation (obj.prop) or square brackets (obj["prop"])
  • Square brackets allow dynamic property access
  • Use delete to remove properties
  • Use in operator to check if property exists
  • Use for...in loop to iterate over object properties
  • Objects are stored and copied by reference
  • Use Object.assign() for shallow cloning
  • Use structuredClone() for deep cloning
  • Property names can be any string (including reserved words)
  • Objects can contain other objects (nested objects)
  • Objects can have methods (functions as properties)
Back to top
JavaScript: Arrays

License: CC0 1.0 Universal

Per aspera, ad astra

  • Edit this page
  • View source
  • Report an issue