Posts Tagged


ES6 – Class, Constructor, Super, Inheritance & Get/Set Stuffs!

ES6 is awesome. Why? It brings a new approach to code in Javascript. It has class and constructor so we can mimic OOP better. class Dog { constructor(name) { this._name = name; } get name() { return this._name; // returning a private variable _name } set name(newName) { let regex = new RegExp(‘^[a-zA-Z0-9.]*$’); if (regex.test(newName))…

Read More

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

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