Q22. What is debouncing in JavaScript?
The debouncing technique prevents a function from being called again until a particular time has passed since the last call.
Its primary application is in Web application search functionality. The API is called only once per user input.
The apply() method invokes a function with the context specified and the arguments provided as an array (or an array-like object).
It is similar to call(), except that it accepts parameters in the form of an array.
The bind() method generates a new function that, when called, has this keyword set to the specified context, with a sequence of arguments preceding it.
It’s similar to call(), except instead of calling the function directly, it returns a copy of the new function.
Syntax Error: The syntax of the program is not correct.
Reference Error: The JavaScript Engine cannot find a reference to a variable or function in memory.
Type Error: Trying to reassign a const variable will lead to a Type Error.
Q26. What is the use of this keyword in JavaScript?
In JavaScript, the this keyword points to the object currently referred.
The this keyword is widely used to assign values to object attributes in constructors.
Q27. What is the difference between async and defer?
In async, while parsing HTML, the browser fetches the script from the network asynchronously if we encounter a script.
After fetching the script, the browser stops parsing HTML and executes the script.
After executing the script, the browser resumes the HTML parsing.
In defer, while parsing HTML, the browser fetches the script from the network asynchronously if we encounter a script. The browser executes the scripts only after parsing the HTML.
Q28. What are cookies?
Cookies are small data packets that the server sends to the client.
The client stores the cookie inside the browser and sends it to the server on each future request.
Q29. What is the difference between let and var keywords?
Both let and const are used for declaring a variable in JavaScript.
The var keyword variables have function scope, while the let keyword variables have block scope.