Js intermediate help | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Js intermediate help

I am having trouble with the object module in js intermediate. I can not understand the lessons: creating objects, object initialization please help

16th Mar 2024, 10:41 AM
Lion
Lion - avatar
2 ответов
+ 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
+ 1
Thanks
17th Mar 2024, 8:09 AM
Lion
Lion - avatar