Category: All Interview Questions
-
What is the difference between Function declaration and Function expression?
Function declaration Function expression Declared as a separate statement within the main JavaScript code Created inside an expression or some other construct Can be called before the function is defined Created when the execution point reaches it; can be used only after that Offers better code readability and better code organization Used when there is…
-
How do you debug a JavaScript code?
All modern web browsers like Chrome, Firefox, etc. have an inbuilt debugger that can be accessed anytime by pressing the relevant key, usually the F12 key. There are several features available to users in the debugging tools. We can also debug a JavaScript code inside a code editor that we use to develop a JavaScript…
-
What is Callback in JavaScript?
In JavaScript, functions are objects and therefore, functions can take other functions as arguments and can also be returned by other functions. Fig: Callback function A callback is a JavaScript function that is passed to another function as an argument or a parameter. This function is to be executed whenever the function that it is passed to gets executed.
-
What are the conventions of naming a variable in JavaScript?
Following are the naming conventions for a variable in JavaScript:
-
What is the ‘this’ keyword in JavaScript?
The ‘this’ keyword in JavaScript refers to the currently calling object. It is commonly used in constructors to assign values to object properties.
-
What are the scopes of a variable in JavaScript?
The scope of a variable implies where the variable has been declared or defined in a JavaScript program. There are two scopes of a variable: Global Scope Global variables, having global scope are available everywhere in a JavaScript code. Local Scope Local variables are accessible only within a function in which they are defined.
-
What are some of the built-in methods in JavaScript?
Built-in Method Values Date() Returns the present date and time concat() Joins two strings and returns the new string push() Adds an item to an array pop() Removes and also returns the last element of an array round() Rounds of the value to the nearest integer and then returns it length() Returns the length of…
-
How do you create an array in JavaScript?
Here is a very simple way of creating arrays in JavaScript using the array literal: var a = [];
-
How do you create an object in JavaScript?
Since JavaScript is essentially an object-oriented scripting language, it supports and encourages the usage of objects while developing web applications. const student = { name: ‘John’, age: 17 }
-
What are the advantages of JavaScript over other web technologies?
These are the advantages of JavaScript: Enhanced Interaction JavaScript adds interaction to otherwise static web pages and makes them react to users’ inputs. Quick Feedback There is no need for a web page to reload when running JavaScript. For example, form input validation. Rich User Interface JavaScript helps in making the UI of web applications…