Skip to main content

Objects: Properties, Copying and Descriptors

Learn Objects: Properties, Copying and Descriptors (Phase 3 · Arrays, Strings, Objects (Essential), JavaScript) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Object basics • An object is a collection of key-value pairs. Keys are strings or symbols; values can be anything, including functions (methods). • Read with dot ( obj.name ) or bracket ( obj["first name"] , or a computed key) notation. Delete with delete obj.key . • Shorthand: { name, age } and shorthand methods { greet() {} } . Test a key with "key" in obj or Object.hasOwn(obj, "key") . • Object.keys , Object.values , Object.entries and Object.fromEntries convert between objects and arrays.

More lessons in Phase 3 · Arrays, Strings, Objects (Essential)