- Object Creation: object literals, constructors,
Object.create()
- Object Methods:
Object.keys()
, Object.values()
, Object.entries()
, Object.assign()
- Prototypes:
__proto__
, Object.getPrototypeOf()
- Property Descriptors
- Object.freeze()
- get set
- Object.defineProperty
Object.keys(obj)
- Returns an array of an object's keys.
let obj = { name: "Alice", age: 25 };
console.log(Object.keys(obj)); // ["name", "age"]
Object.values(obj)
- Returns an array of an object's values.
console.log(Object.values(obj)); // ["Alice", 25]
Object.entries(obj)
- Returns an array of
[key, value]
pairs.
console.log(Object.entries(obj));
// [["name", "Alice"], ["age", 25]]
Object.assign(target, source)
- Merges objects into the
target
object.
let obj1 = { a: 1 }, obj2 = { b: 2 };
let merged = Object.assign({}, obj1, obj2);
console.log(merged); // { a: 1, b: 2 }
Object.hasOwnProperty(key)