JavaScript Tutorial – 10: JavaScript Object

Object syntax: “key”: “value”
– object can have object & function as well
– array as well as they are objects

– We can access a property using . notation
– We can add or remove property anytime
– i.e. = 1988
delete movie.category
– We can add using . or [”]
– When you want to add dynamic name of property, use []

– Object from function (Factory Function)
when you need to create multiple object, create function & return
– just for chnaging name, you created two objects
– have function with parameters
– In function directly return
– If key & value is same, just have the key
– We can call this function as Factory Function

– Object using a Constructor function
– they are function, but 1st character is big
– instead of returning a object, use ‘this’
– ‘this’ is reference for using in current object
– We create using new operator, so it underatands we’re calling constructor function
– If ‘this’ is in Constructor function, ‘this’ will reference top current object.,
but if you do not use ‘new’, ‘this’ will refer to global object

– You can Enumerate on Object, using for…in on key
– for…of can used only with iterable & Object is not iterable, so use for…in
– or get Object.keys(circle) to get keys of object, which can be iterable
– you can get key & value by Object.entries(circle) & then ietrate on for…of
– you can also check if property exists in object using ‘in’

– cloning a object
– using for…in, copy each property,
– const movie1 = Object.assign({}, movie);
– {} can be empty or can have existing property
– const movie1 = { …movie };
copy all property & copy them into another object

This problem is similar to following:
What is JavaScript object,
Introduction to javascript object,
how object in javascript,
javascript object,
how to access a javascript object property,
how to clone a javascript object,
create object using constructor function,
create object using factory function,
how to iterate on object,
delete object property,
javascript tutorial,
javascript operators tutorial,
coding simplified


I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I’ve published over 300+ videos. My account is Partner Verified.



★☆★ SEND EMAIL At: ★☆★

Original source

Leave a Reply