declare an object in Javascript
Code snippet on how to declare an object in Javascript
let car = {
make: "Toyota",
model: "Corolla",
year: 2018
};
This code creates an object named “car” in JavaScript. The object has three properties, which are “make” (the car make, in this case Toyota), “model” (the car model, in this case Corolla), and “year” (the model year, in this case 2018). The syntax for objects in JavaScript uses curly brackets { } which encase the property names and values. Each property is separated by a comma and the name and value are separated by a colon. The value of a property can be a string, number, boolean, function, array, or even another object. In this example, all of the properties are strings.