Learn Before
Concept
Object initializer
An object initializer is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ({}). Objects can also be initialized using Object.create() or by invoking a constructor function with the new operator.
const object1 = { a: 'foo', b: 42, c: {} }; console.log(object1.a); // Expected output: "foo" const a = 'foo'; const b = 42; const c = {}; const object2 = { a: a, b: b, c: c }; console.log(object2.b); // Expected output: 42 const object3 = { a, b, c }; console.log(object3.a); // Expected output: "foo"
0
1
Updated 2023-03-21
Tags
Object-Oriented Programming (OOP) Languages
Object-Oriented Programming
Programming Language Paradigms
General programming languages
Computing Sciences