f.prototype and constructor (js)


[DRAWING HERE] In modern JavaScript we can set a prototype using __proto__. But in the old times, there was another (and the only) way to set it: to use a “prototype” property of the constructor function. It is known that, when “new F()” creates a new object… the new object’s [[Prototype]] is set […]

Constructors (js)

https://javascript.info/constructor-new The purpose of constructors is to implement reusable object creation code Constructor functions technically are regular functions. There are two conventions though: They are named with capital letter first. They should be executed only with “new” operator. Every function is an object, and when an object is created with “new”, it runs through the […]

null vs undefined (js)

https://stackoverflow.com/questions/801032/why-is-null-an-object-and-whats-the-difference-between-null-and-undefined The difference between null and undefined is as follows: undefined undefined: used by JavaScript and means “no value”. – Uninitialized variables – missing parameters – unknown variables have that value. > var noValueYet; > console.log(noValueYet); undefined > function foo(x) { console.log(x) } > foo() undefined > var obj = {}; > console.log(obj.unknownProperty) undefined null […]

Stack and Heap

https://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap?rq=1 The stack is the memory set aside as scratch space for a thread of execution. When a function is called, a block is reserved on the top of the stack for local variables, parameters, and some bookkeeping data. When that function returns (finishes execution), the block becomes unused (all the variables gets popped) and […]

Javascript memory allocation

https://stackoverflow.com/questions/2800463/how-variables-are-allocated-memory-in-javascript https://stackoverflow.com/questions/1026495/does-javascript-have-a-memory-heap When you call a function, amongst other things a variable environment for that call is created, which has something called a “variable object”. The “variable object” has properties for the – arguments to the function – all local variables declared in the function – and all functions declared within the function (along with […]

Javascript pass by reference or pass by value

https://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language?rq=1 Javascript parameters are pass by value, the value is that of the reference address.

obj1 is a reference that points to the object. Specifically, it points to the address of the object. In the function changeStuff, its parameter ‘numParam’ is pushed as a reference on to the local function stack. It then copies […]

Typing in javascript

https://stackoverflow.com/questions/964910/is-javascript-an-untyped-language strong/weak can be thought of in relation to how the compiler, if applicable, handles typing. Weakly typed means the compiler, if applicable, doesn’t enforce correct typing. Without implicit compiler interjection, the instruction will error during run-time. “12345” * 1 === 12345 // string * number => number Strongly typed means there is a compiler, […]

Arrow function (e6 js)

For arrow functions, this is picked up from surroundings (lexical). In other words, Arrow functions are lexically scoped; this means that their ‘this’ is bound to the context of the surrounding scope That is to say, whatever ‘this’ refers to can be preserved by using an arrow function.

output: Test2() Constructor: Jabba the Hut […]

Closures (inner functions)

https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-closure-b2f0d2152b36 A closure is the local variables for a function – kept alive after the function has returned A closure is a stack-frame (which contains accessible variables), which has not been deallocated when the function returns. (as if a ‘stack-frame’ were malloc’ed instead of being on the stack!) Closures, Inner Functions ECMAScript allows inner functions; […]


https://www.w3schools.com/xml/ XML stands for eXtensible Markup Language. XML was designed to store and transport data. XML was designed to be both human- and machine-readable. XML stands for eXtensible Markup Language XML is a markup language much like HTML XML was designed to store and transport data XML was designed to be self-descriptive XML is a […]