The differences between var, let, and const variable declaration in JavaScript include: Variables declared with var and const are scoped to the immediate function body. Variables declared with the var keyword are hoisted. Hoisting means that the variable can be accessed in their enclosing scope even before they are declared. Variables declared with the let keyword are block-scoped, which means the variables will have scope to the immediate enclosing block.
A programmer can get the same result as regular functions by writing
a few lines of code using arrow functions. Curly brackets are not
required if only one expression is present.
arguments object
inside the regular functions contains the list of arguments.
Inside of a regular JavaScript function, this value is
dynamic. The dynamic context means that the value of this depends on
how the function is invoked.
The behavior of this inside of an
arrow, function differs considerably from the regular function’s
this behavior as an arrow function does not have its own “this”
keyword.
Regular functions are constructible and callable.
They can be called using the new keyword.
But, the arrow
functions are only callable and not constructible, i.e., arrow
functions can never be used as constructor functions.
the most compelling case for using .forEach() in favor of a for loop
is that it’s easier. Even though it’s the same number of lines,
there’s less setup. If the fact that it’s easier, isn’t enough for
you… there is also a technical reason to use .forEach() in favor of
for loops. It has to do with the scoping of the code.
.map() when you want to transform elements in an array.
.filter() when you want to select a subset of multiple
elements from an array.
.filter() when you want to select a
subset of multiple elements from an array.
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.
Copyright 2021 NEWS 247