JavaScript variables serve as containers for data values.
The following code assigns a simple value (Fiat) to a variable named car:
Example
let car = “Fiat”; |
Objects are also variables, but they can hold multiple values.
This code assigns several values (Fiat, 500, white) to an object named car:
Example
const car = {type:“Fiat”, model:“500”, color:“white”}; |
Note: It is common practice to declare objects using the const keyword. |