1.what is object is javascript?
In javascript objcet is a collection key-value paris
where the key
is a string
and the value
can be anything — a number, string, boolean, array, function, or even another object.
syntax:
let obj = {
key1: value1,
key2: value2,
key3: value3
};
example:
const car = {
type:"Fiat", model:"500", color:"white"
};
{ } -> object properites - informations are called as propertites.
objcet is a variable that can hold variable.
you should create object using const.
you can also create the empty object.
empty object:
const person = {};
// Add Properties
person.firstName = "John";
person.lastName = "Doe";
person.age = 50;
person.eyeColor = "blue";
Top comments (0)