Skip to content

Instantly share code, notes, and snippets.

@thamsrang
Last active April 10, 2021 08:18
Show Gist options
  • Save thamsrang/6f248c65780cbd1878a5b5c7979d1cbd to your computer and use it in GitHub Desktop.
Save thamsrang/6f248c65780cbd1878a5b5c7979d1cbd to your computer and use it in GitHub Desktop.

Object.defineProperty()

  • configurable
  • enumerable
  • writable
  • value
  • get & set function

References

prototype vs __proto__

All objects have an internal property called [[Prototype]]. The value of this property is either null or an object and is used for implementing inheritance.

[[Prototype]]

  • An object specifies its prototype via the internal property

proto

  • This brings direct access to [[Prototype]] to the language(by speakingjs.com).

  • __proto__ is the actual object that is used in the lookup chain to resolve methods, etc. prototype is the object that is used to build __proto__ when you create an object with new:

prototype

  • prototype is the object that is used to build __proto__ when you create an object with new.
  • prototype is not available on the instances themselves (or other objects), but only on the constructor functions.
  • prototype is only available on functions since they are copied from Function and Object, but in anything else it is not. However, __proto__ is available everywhere.
( new Foo ).__proto__ === Foo.prototype;
( new Foo ).prototype === undefined;

Reference:

Object.freeze vs Object.seal vs Object.preventextensions

Object freeze vs seal vs preventextensions

Reference

Object Inheritence

Object Clone

Deep copy

Convert JSON and back

 JSON.parse(JSON.stringify(nestedObject));

Swallow copy

  1. Spreed Operator
  2. Object.assign({}, Obj1)

Reference

Object.getOwnPropertyDescriptor(s)()

Object.is(obj1, obj2) - Compare two Object

native object vs Host Object

https://stackoverflow.com/a/7614380

class (static) method vs class prototype method

My other useful GIST


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment