Modern JavaScript Part 12: ES6 Classes

Quoting MDN: classes are primarily syntactical sugar over js’s existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript. That being said, let’s review prototypal inheritance before we jump into classes. function Person(name,age) { this.name = name; this.age = age; } Person.prototype.greet = function(){ Read more…

Modern JavaScript Part 6: Destructuring

MDN defines destructuring like this: The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. Let’s start with destructuring objects first.   Destructuring Objects To create variables from an object we used to do this: var Read more…

Modern JavaScript Part 5: Additional string methods

Additional string methods We are going to cover 4 new strings method: startsWith() endsWith() includes() repeat()   startsWith() This new method will check if the string starts with the value we pass in: const code = "ABCDEFG"; code.startsWith("ABB"); // false code.startsWith("abc"); // false, startsWith is case sensitive code.startsWith("ABC"); // true Read more…