Loading...
Loading...
Loading...
Loading...

No News Found...

Some Question and Answers

Answer: 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 and const keyword are block-scoped, which means the variables will have scope to the immediate enclosing block.
• While var and let can be re-declared without being initialized but const should be initialized during declaration.
• They all are hoisted at the top but with var, it is initialized with a default value, unlike let and const are not initialized.
• For scoping and re-declaration see the below table for better clarity

Answer: Some differences are given below:
1.Argument Bindings:
Arguments object inside the regular functions contains the list of arguments

The arrow function, on the opposite, does not define arguments i.e. they do not have arguments binding.

2. Use of this keyword:
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 from the regular function’s this behavior as an arrow function does not have its own “this” keyword.
The value of this inside an arrow function remains the same throughout the lifecycle of the function. No matter how or where being executed, this value inside of an arrow function always equals this value from the outer function.

Answer:

.map() : Function .map() is a manipulative function that can modify each element’s content in an array that it is called on. This function returns a new array with modified values, the array that it is called on will stay still. This function is useful for adding a little change to an already existing array, for example adding a property to an object or modifying it.

.forEach() : this function is used to execute the same code on every element in an array but does not change the array. The forEach() method returns “undefined“.

.filter() : .filter() is a function that returns all the elements that fulfil the assigned condition. You can search by simple terms, for example, that element is equal to a certain integer, or by more advanced terms, for example, searching for an object with certain property that is equal to something. This function returns an array of found results, even if only 1 match is found. If a function does not find any match, it simply returns an empty array.

.find() : .find() is also a search function like .filter() but they differ in one small detail. This .find() function returns only one match in an array. If in an array is more than one result, the function will return the first that has matched.


Answer:

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. However, a tagged template literal may not result in a string but it can be used with a custom tag function to perform whatever operations you want on the different parts of the template literal.