...
Var, Let, and Const – What's the Difference?

Var
Before the advent of ES6, var declarations ruled. There are issues associated with variables declared with var, though. That is why it was necessary for new ways to declare variables to emerge. First, let's get to understand var more before we discuss those issues.

Let
let is now preferred for variable declaration. It's no surprise as it comes as an improvement to var declarations. It also solves the problem with var that we just covered. Let's consider why this is so.

Const
Variables declared with the const maintain constant values. const declarations share some similarities with let declarations. const declarations are block scoped Like let declarations, const declarations can only be accessed within the block they were declared.

Last updated 3 mins ago

...
The Difference Between Regular Functions and Arrow Functions

Arrow function — also called fat arrow function— is a new feature introduced in ES6 that is a more concise syntax for writing function expressions. While both regular JavaScript functions and arrow functions work in a similar manner, there are certain differences between them.

1.Syntax
The arrow function example above allows a developer to accomplish the same result with fewer lines of code and approximately half the typing.

2. Arguments binding
Arrow functions do not have an arguments binding. However, they have access to the arguments object of the closest non-arrow parent function. Named and rest parameters are heavily relied upon to capture the arguments passed to arrow functions.

3. Use of this keyword
Unlike regular functions, arrow functions do not have their own this. The value of this inside an arrow function remains the same throughout the lifecycle of the function and is always bound to the value of this in the closest non-arrow parent function.

Last updated 3 mins ago

...
.forEach(), .map(), .filter() .... What's the difference?

.forEach:
.forEach(), is used to execute the same code on every element in an array but does not change the array and it returns undefined.

.map():
.map() executes the same code on every element in an array and returns a new array with the updated elements.

.filter():
.filter() checks every element in an array to see if it meets a certain criteria and returns a new array with the elements that return truthy for the criteria.

Last updated 3 mins ago

...
Template Strings in JavaScript

Template strings are a powerful feature of modern JavaScript released in ES6. It lets us insert/interpolate variables and expressions into strings without needing to concatenate like in older versions of JavaScript. It allows us to create strings that are complex and contain dynamic elements. Another great thing that comes with template strings are tags. Tags are functions that take a string and the decomposed parts of the string as parameters and are great for converting strings to different entities.

Multiline Strings
Another great feature of template strings is that we can have strings with multiple lines for better code readability. This cannot be done in an easy way with the old style of strings.

Last updated 3 mins ago