var, hoisting, and temporary deadzones (js)

ref – http://adripofjavascript.com/blog/drips/variable-and-function-hoisting.html http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified 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 – https://stackoverflow.com/questions/2391679/why-do-we-need-virtual-functions-in-c?rq=1 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)

https://stackoverflow.com/questions/931872/what-s-the-difference-between-array-and-while-declaring-a-javascript-ar https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array https://medium.com/@gamshan001/javascript-deep-copy-for-array-and-object-97e3d4bc401a 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 – https://javascriptplayground.com/es5-getters-setters/ 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

https://hackernoon.com/inheritance-in-javascript-21d2b82ffa6f 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

https://hackernoon.com/prototypes-in-javascript-5bba2990e04b 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 […]