A basic introduction on what a primitive and an object are in JavaScript, how do they behave in a JS engine, and differences between them. Also explaining basic aspects of prototypal inheritance.
values ‒ How they work But how they work? Every time an operation happens on a primitive that has a related prototype, it is wrapped into an object, which is thrown away just after finishing the operation on it.
to length - 1, and are Array instances. • Remember, all keys are strings! • But they are usually not represented as hashmaps in memory; rather on a more efficient way.
Typical array-like objects are the arguments object, or returned from querySelectorAll. var elements = document.querySelectorAll('head, body'); console.log(elements.length); //Shows 2. console.log(Object.keys(elements)); //Shows ['0', '1', 'length']. console.log(elements instanceof Array); //Shows false. var arrayElements = Array.prototype.slice.call(elements);