var, hoisting, and temporary deadzones (js)

ref – Hoisting is about a variable or function definition (that’s being used or initialized) being available beforehand. For example, if we declare and initialize a variable to a string, that variable is actually available beforehand at the very top. This is because the interpreter will get all the variables, and declare them […]

references, values in Javascript

There are no pointers in Javascript In JavaScript, a variable may store two types of data: primitive reference JavaScript provides six primitive types as undefined, null, boolean, number, string, and symbol. Reference are Objects and Arrays. When you assign a variable a value, the JavaScript engine must determine whether the value is a primitive or […]

Why use Virtual (C++)

ref – Simple Over-riding Without “virtual” you get “early binding”. Which implementation of the method is used gets decided at compile time based on the type of the pointer that you call through.

OUTPUT: Constructing Shape Constructing Circle Constructing Shape SHAPE: Draw function SHAPE: Draw function Using Virtual

OUTPUT: Constructing Shape Constructing […]

Arrays (js) Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array’s length can change at any time, and data can be stored at non-contiguous locations in the array, JavaScript arrays are […]

getter setter (JS)

ref – this is ugly:

But this is ugly, and requires the users of your object to care that the properties are related; in a more complex example, that might not be as obvious as with names. Luckily, there’s a better way, added in ECMAScript 5.

we see that we have a […]

Chaining Prototype Example of chained prototype. Hierarchy basics – Object Firstly, all functions derive from “Object”, where “Object” is the default base of all javascript objects. The idea behind how hierarchy is laid out in JS is that the Object definition references an empty object called Object Prototype via a reference called “prototype”. This Object Prototype […]

prototype, __proto__, object specifics, and sharing via prototype Object.prototype is one of the rare objects that has no prototype: it does not inherit any properties. Step 1: Every object in Javascript is derived from base Object. Base Object has many built-in properties, with its prototype pointing to an empty “Object prototype”. Hence, in memory we see “function Object” which has a prototype […]