A lot of shiny new features came out with ES2015 (ES6). And now, since it's 2020, it's assumed that a lot of JavaScript developers have become familiar with and have started using these features. While this assumption might be partially true, it's still possible that some of these features remain a mystery to some devs. One of the features that came with ES6 is the addition of let and const, which can be used for variable declaration. The question is, what makes them different from good ol' var which we've been using? If you are still not clear about this, then this article is for you. In this article, we'll discuss var, let and const with respect to their scope, use, and hoisting. As you read, take note of the differences between them that I'll point out.

Regular functions created using function declarations or expressions are constructible and callable. Since regular functions are constructible, they can be called using the new keyword. However, the arrow functions are only callable and not constructible, i.e arrow functions can never be used as constructor functions. The arrow function example above allows a developer to accomplish the same result with fewer lines of code and approximately half the typing. Curly brackets aren’t required if only one expression is present. The above example can also be written like this:

.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. Example: In the example below we would use .forEach() to iterate over an array of food and log that we would want to eat each of them. let food = ['mango','rice','pepper','pear']; food.forEach(function(foodItem){ console.log('I want to eat '+foodItem); }); .map() executes the same code on every element in an array and returns a new array with the updated elements. .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.

Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, for string interpolation with embedded expressions, and for special constructs called tagged templates. Template literals are sometimes informally called template strings, because they are used most commonly for string interpolation (to create strings by doing substitution of placeholders). However, a tagged template literal may not result in a string; it can be used with a custom tag function to perform whatever operations you want on the different parts of the template literal.