Posts Tagged


What is “this” in Javascript?

What is “this” in Javascript – especially, when you use bind( ), arrow function and regular function?   this refers to its closest object. Maya, you’re not making any sense! Wait, let me explain.  If this is called in a global scope, then this refers to “window” object in a browser or “global” object in Node. function…

Read More

How To Use Reduce( ) in Javascript

[10,1000].reduce( (finalValue, whatToAddToFinalValue) => finalValue + whatToAddToFinalValue ); The array has 2 items [10, 1000], which means we run 2 iterations. On each iteration, reduces() takes 1 item ONLY! For the FIRST iteration, since we did not declare the finalValue starting value, so it will always be 0 : We have whatToAddToFinalValue variable, which will…

Read More

For VS While Loop in Javascript

When we need to perform similar actions for certain number of times, that is when we get to “Looping”. For example, when we need to output goods from a list one after another. Or just run the same code for each number from 1 to 10. Loops are a way to repeat the same part…

Read More

Semicolons in Javascript – Where and when?

Semicolon ; is placed at the end of an object declaration, assignment and a return statement. Without a semicolon, the code will be considered “undone”. So a statement will not be a statement, an assignment will not assign anything, a declaration will not declare anything. but wait, read this and this too. What? You are still gonna…

Read More

Javascript (Var vs Let vs Const)

VAR Var is functioned-scoped and variables defined in the function CAN NOT be accessed from its outer function. But variables can be accessed from its inner function. Children-scoped variables can USE its parents variables. Parents can not use its children variables – because … well, yeah, children like to keep secrets 😀 Var is hoisted…

Read More