Let's Learn Vocabularies
আপনি এখনো কোন Lesson Select করেন নি
একটি Lesson Select করুন।
Frequently Asked Questions
1.What is the difference between var,let,and const?
Sl | var | let | const |
---|---|---|---|
01 | var is a Function-scoped (or global if declared outside any function) and it can be re-Declare and re-Assigned in the same scope without throwing an error and var hoisted to the top of its scope and initialized it with undefined. | let is a block-scoped and if we declare a variable using let it can not be re declare but it's value can be change and update means it can be re assigned. | const is also a block-scoped but it does not allow reassignment or redeclare,means if we declare a variable using const it value can not be changed if it is initially set but the contents of object or array can be modified inside const variable |
2.What is the difference between map(), forEach(), and filter()?
Sl | map() | forEach() | filter() |
---|---|---|---|
01 | The map() function receives a function as a parameter and will apply the code on each given array element and returns an entirely new array. It will not change the original array.A map() function returns a new array | The forEach() method is used to execute a provided function once for all element in a given array.It does not return anything ,it is used to perform a operation for all array element, which is declared in a function | The filter() method return a new array with all array element that pass a test which is provided by a function |
3.Explain arrow functions and how they are different from regular functions.
Arrow Function is introduced in ES6,it is a simple and easy way for writing function in JavaScript.The difference between arrow function and regular function is that arrow function has a shorter syntax and does not have its own arguments object while a regular function has an arguments object.
4.How JavaScript Promises work.
In JavaScript a promise is an object that represents the completion or failure of an asynchronous operation.A JavaScript promise object can be i.Pending,ii.Resolve,iii.Reject.A promise is starts in a Pending state and that can be either resolve(success) or reject(failure).The result is handled using .then() for success , .catch() for errors and .finally() for code that runs in both cases.This is how promise works in JavaScript.
5.How closures work in JavaScript?.
In JavaScript when a function remembers the variables from its outer scope even after the outer function has finished executing this is called closures.When a function is created inside another function the inner function returns a reference to the outer function's variables ,this means that even after the outer function has finished execution , the inner function can still access those variables.