I have summary of few great points from the book "the principles of object oriented javascript by nicholas c zakas" as below.
- Primitive values are stored directly on the variable object, while reference values are placed as a pointer in the variable object, which serves as a reference to a location in memory where the object is stored
- JavaScript is a garbage-collected language, so you don’t really need to worry about memory allocations when you use reference types. However, it’s best to dereference objects that you no longer need so that the garbage collector can free up that memory. The best way to do this is to set the object variable to null.
- To identify reference types more easily, you can use JavaScript’s instance of operator
- The arguments object is not an instance of Array and therefore doesn’t have the same methods as an array; Array.isArray(arguments) always returns false.
- The number of arguments a function expects is stored on the function’s length property. Remember, a function is actually just an object, so it can have properties
- In practice, checking the named parameter against undefined is more common than relying on arguments.length
- Because all instances of a particular type reference a shared prototype, you can augment all of those objects together at any time. Remember, the [[Prototype]] property just contains a pointer to the prototype, and any changes to the prototype are immediately available on any instance referencing it. That means you can literally add new members to a prototype at any point and have those changes reflected on existing instances