🔸property
has a name, a value and 3 attributes.
JS ⟩ value ⟩ object ⟩ property
a property has a name, a value, and 3 attributes.
there are two types of properties:
(function property) stores a function (method/getter/setter/).
// defining/creating properties
{ name: value } // object literal
obj.prop = value // create property 'on the fly'
// accessing properties
obj . prop // `prop` must be an identifier
obj [ prop ] // `prop` convereted to String or it's a Symbol.accessing properties
optional chaining (?., ?.[]) - safely access object's properties.
delete properties
features of a property
attribute - writable, enumerable, configurable.
Every property in JavaScript objects can be classified by 3 factors:
enumerable / non-enumerable
own / inherited (from the prototype chain)
👉 property testing (📘 MSN )
in the global scope,
var / function are implemented as propery on the global object.
these properies can't be deleted❗
global let / const are not properies of the global object❗
closure can be used as a function with private propery (functions/variables)❗(👉 closure: manage grades)
object's configurable properies can be deleted❗
replit:object properties
Last updated
Was this helpful?