Object Basics in JavaScript
From the JavaScript cheat sheet · Objects & Arrays · verified Jul 2026
Object Basics
Creating and manipulating objects
javascript
// Object literal
const person = {
name: 'John',
age: 30,
greet() {
return `Hello, I'm ${this.name}`;
}
};
// Accessing properties
person.name; // 'John'
person['age']; // 30
// Adding/modifying
person.email = 'john@example.com';
delete person.age;💡 Use dot notation for simple keys, brackets for dynamic/special keys
⚡ Object.assign and spread create shallow copies only
📌 in operator checks prototype chain, hasOwnProperty doesn't
🟢 See also: Array Methods sheet (map, filter, reduce) and String Methods sheet (split, slice, replace)