You don't know JS: Summary - Chapter 3 (this and Prototype)

You don't know JS: Summary - Chapter 3 (this and Prototype)

  1. You can add one or more key/value pairs to the literal declaration, whereas with constructed-form objects, you must add the properties one by one.

  2. Date lues can "only" be created with their constructed object form, as they have no literal form counterpart.

  3. The .a syntax is usually referred to as "property access" whereas the ["a"] syntax is usually referred to as "key access".

  4. A Shallow copy is fairly understandable and has far fewer issues, so ES6 has now defined Object.assign(...) for this task. Object.assign(...) takes a target object as its first parameter and one or more source objects as its subsequent parameters. It iterates over all the enumerable, owned keys on the source object and copies them to the target.

  5. Object.getOwnPropertyDescriptor() includes three characteristics: writable, enumerable and configurable.

  6. Ability to change the value of the property is controlled by writable, to change the configuration of the object is controlled by configurable, and whether the property will show up in enumerations like for...in loop, is controlled by enumerable.

  7. For a constant object, writable: false and configurable: false.

  8. If you want to prevent an object from having new properties added to it, but otherwise leave the rest of the object's properties alone, call object.preventextensions(...).

  9. Object.seal(...) takes an existing object and essentially calls Object.preventExtensions(..)on it, but also marks all its existing properties as configurable: false.

  10. Object.freeze(..) creates a frozen object, which means it takes an existing object and essentially calls Object.seal(..) on it, but it also marks all "data accessor" properties as writable: false, so that their values cannot be changed.

  11. hasOwnProperty(..) is accessible for all normal objects via delegation to Object.prototype.

  12. It's good to use for...in loops only on objects, and traditional for loops with numeric index iteration for arrays.

  13. Object.keys(...) returns an array of all enumerable properties, whereas Object.getOwnPropertyNames(..) returns n array of all properties enumerable or not.

  14. ES6 adds a for..of loop syntax for iterating over arrays.


If you want similar content, then visit iaminnovativecoder.com

Follow me on : YouTube - youtube.com/InnovativeCoder Instagram - instagram.com/innovative_coder