What is the differences between arrow function and regular function?

Show Answer

JavaScript's arrow functions might seem the same as regular functions on the surface, but they have some very important differences: Syntactical differences this value (execution context) Usage as methods Usage as constructors arguments binding Syntax The first and most obvious difference between arrow functions and regular functions is their syntax. Not only do they look different, but arrow functions also provide an implicit return shorthand and allow parenthesis around a single argument to be omitted.


                     (param1, param2, paramN) => expression // ES5 Regular function
                    var add = function(x, y) {
                    return x + y;
                    }; // ES6 Arrow function
                    let add = (x, y) => { return x + y };
                    

What are the difference among var, let and const?

Show Answer

What are the difference among map, foreach, filter and find?

Show Answer

` Those are really powerful array functions. The principle differances written below: map returns an array with the same length, filter as the name implies, it returns an array with less items than the original array. .forEach() is great you need to execute a function for each individual element in an array. find returns the first items in an array that satisfies a condition When to use map? .map() when you want to transform elements in an array. When to use filter? .filter() when you want to select a subset of multiple elements from an array. When to use find? .find() When you want to select a single element from an array.`

Why we use template string? What is the advantages of template string?

Show Answer

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. The syntax for creating template strings is by using backticks to delimit them. For example, we can write: `This is a string` This is a very simple example of a template string. All the content is constant and there are no variables or expressions in it.