+ 2
You can create an object using an object initializer. const obj = { property1: value1, // property name may be an identifier 2: value2, // or a number "property n": value3, // or a string }; Alternatively, you can first create a constructor function function Car(make, model, year) { this.make = make; this.model = model; this.year = year; } and then instantiate an object by invoking that function with the new operator const myCar = new Car("Eagle", "Talon TSi", 1993);
16th Mar 2024, 1:30 PM
JaScript
JaScript - avatar