Search results
24 wrz 2024 · Struggling to find a frontend job? Make sure you can answer these 17 JavaScript variable questions first 👇: 1. What is a variable in JavaScript? A variable is a container that holds data. You can think of it as a label for a specific spot in memory where information is stored.
11 cze 2024 · Question 18. Explain call, apply, and bind methods in JavaScript.Answer: ´call´ and ´apply´ methods invoke a function with a specified ´this´ context. ´call´ takes arguments separately while ´apply´ takes arguments as an array. ´bind´ returns a new function, permanently bound to the provided ´this´ context. Question 19.
29 kwi 2024 · 11. What are global variables? How are these variable declared? Global variables are available throughout the length of the code so that it has no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared. Example: // Declare a global: globalVariable = “Test”;
30 paź 2024 · JavaScript interview questions range from the basics like explaining the different data types in JavaScript to more complicated concepts like generator functions and async and await. Each question will have answers and examples you can use to prepare for your own interview.
3 sty 2024 · Example 2: var obj = { name: "vivek", getName: function(){ console.log (this.name); } } obj.getName (); In the above code, at the time of invocation, the getName function is a property of the object obj , therefore, this keyword will refer to the object obj, and hence the output will be “vivek”. Example 3:
Q4. What are global variables, and how can you declare them? Answer: Global variables are memory allocations that can be used throughout the program (or you can say it has a global scope). In JavaScript, you can use the var keyword to declare any local variable or object.
3 sty 2020 · The best use of IIFE is making initialization setup functionalities and to avoid naming collisions with other variables in the global scope or polluting the global namespace. Let's have an example.