0% found this document useful (0 votes)
5 views

Question on Javascript

Uploaded by

Sindhura S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Question on Javascript

Uploaded by

Sindhura S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Variables (var, let, const):

1. What are the differences between `var`, `let`, and `const` in JavaScript?

2. How does variable hoisting differ between `var`, `let`, and `const`?

3. When would you use `let` or `const` instead of `var`, and why?

4. Can you explain the concept of block-scoping with `let` and `const`?

**Data Types (String, Number, Boolean, Object, Array):**

1. Explain the difference between primitive data types and objects in JavaScript.

2. How do you check the data type of a variable in JavaScript?

3. What are the methods available for string manipulation in JavaScript?

4. How can you convert a string to a number and vice versa in JavaScript?

5. How do you create an array in JavaScript, and what methods can you use to manipulate arrays?

**Operators (Arithmetic, Comparison, Logical, Assignment, Ternary):**

1. Explain the difference between `==` and `===` operators in JavaScript.

2. What is the ternary operator, and how is it used?

3. How do short-circuit evaluation and logical operators work in JavaScript?

4. Can you explain the concept of operator precedence in JavaScript?

**Control Structures (if...else, switch, loops):**

1. What is the difference between `if...else` and `switch` statements?

2. How do you break out of a loop prematurely in JavaScript?

3. What is the difference between `for` and `while` loops?

4. Can you explain the concept of the "truthy" and "falsy" values in JavaScript control structures?

**Functions (Declaration, Expressions, Parameters, Return):**

1. What is the difference between function declarations and function expressions?

2. How do you define default parameter values for a function in JavaScript?

3. What is a higher-order function, and can you provide an example?

4. How does the `return` statement work in JavaScript functions?


**Arrays (Methods, Iteration):**

1. Explain the difference between the `forEach`, `map`, `filter`, and `reduce` methods in JavaScript
arrays.

2. How can you add or remove elements from an array in JavaScript?

3. What is the difference between `slice()` and `splice()` methods?

4. How do you loop through an array in JavaScript?

**Objects (Properties, Methods, Constructors, Prototypes):**

1. What is the difference between object properties and methods in JavaScript?

2. How do you create an object constructor function in JavaScript?

3. What are prototypes in JavaScript, and how do they relate to object inheritance?

4. Explain the concept of object destructuring in JavaScript.

**Scope (Global, Local, Block):**

1. What is variable scope in JavaScript?

2. How do you define a variable in the global scope?

3. Can you explain the concept of shadowing in variable scope?

4. How does block scope differ from function scope in JavaScript?

**Closures:**

1. What is a closure in JavaScript, and how is it created?

2. Can you provide an example of a practical use case for closures?

3. How does garbage collection work with closures in JavaScript?

4. What are the benefits and drawbacks of using closures in JavaScript?

**Callbacks:**

1. What is a callback function in JavaScript, and how is it used?

2. Can you explain the concept of callback hell and how to avoid it?

3. How do you pass arguments to a callback function in JavaScript?

4. What are some common asynchronous operations where callback functions are used?
**Promises:**

1. What is a Promise in JavaScript, and how does it differ from callbacks?

2. How do you handle errors with Promises?

3. What are Promise chaining and Promise.all in JavaScript?

4. How does the async/await syntax simplify asynchronous programming compared to Promises?

**Asynchronous Programming (Callbacks, Promises, Async/Await):**

1. Explain the difference between synchronous and asynchronous JavaScript code execution.

2. How do you handle asynchronous operations with callback functions?

3. What are some advantages of using Promises over callback functions for handling asynchronous
code?

4. How does the `async/await` syntax improve readability and maintainability of asynchronous code?

Constructor Functions:

1. How do you define a constructor function in JavaScript?


2. What is the purpose of using the new keyword with constructor functions?
3. How do you add properties and methods to objects created by a constructor function?
4. Can you explain the difference between constructor functions and class syntax
introduced in ES6?

Higher-Order Functions:

1. Provide an example of a higher-order function in JavaScript.


2. How do higher-order functions enable code reusability and abstraction?
3. Explain the concept of function composition with higher-order functions.
4. How can you use higher-order functions to implement features like map, filter, and
reduce?

Anonymous Functions:

1. What is an anonymous function, and why are they used?


2. How do you define an anonymous function in JavaScript?
3. What are the advantages and disadvantages of using anonymous functions?
4. Can you provide an example of using an anonymous function as a callback?

Function Declarations:

1. What is a function declaration in JavaScript?


2. How are function declarations hoisted in JavaScript?
3. Explain the difference between function declarations and function expressions.
4. When would you use a function declaration over a function expression?

Function Expressions:

1. How do you define a function expression in JavaScript?


2. What is the main difference between function declarations and function expressions?
3. Can you explain how function expressions are treated by the JavaScript engine during
execution?
4. Provide an example of using a function expression as a callback function.

Arrow Functions:

1. What are arrow functions, and when were they introduced in JavaScript?
2. How do arrow functions differ syntactically from regular function expressions?
3. What is lexical scoping, and how does it apply to arrow functions?
4. Can you provide an example of using arrow functions in a practical scenario?

Immediately Invoked Function Expressions (IIFE):

1. What is an IIFE, and why are they used in JavaScript?


2. How do you define an IIFE in JavaScript?
3. Explain how IIFEs help avoid polluting the global scope.
4. Provide a use case where you would employ an IIFE.

Higher Order Function:

1. What is a higher-order function?


2. Provide examples of higher-order functions in JavaScript standard libraries.
3. How do higher-order functions facilitate functional programming in JavaScript?
4. Can you explain the concept of currying and how it relates to higher-order functions?

Anonymous Functions:

1. What is an anonymous function?


2. How are anonymous functions used in JavaScript?
3. Provide an example of using an anonymous function as a callback.
4. What are the benefits of using anonymous functions?

Callback Functions:

1. What are callback functions?


2. How are callback functions used in JavaScript?
3. Provide examples of built-in functions in JavaScript that accept callback functions as
arguments.
4. What are the advantages of using callback functions?

DOM (Document Object Model):

1. What is the DOM, and how is it structured in relation to HTML documents?


2. How do you select elements in the DOM using JavaScript?
3. What are some methods available for manipulating the DOM?
4. Explain the concept of event bubbling and how it relates to the DOM.

Selectors in DOM:

1. How do you select elements by ID, class, or tag name in the DOM?
2. What are the differences between querySelector() and getElementById()?
3. Explain the purpose of using CSS selectors in conjunction with JavaScript.
4. How do you select multiple elements using a single selector?

createElement:

1. How do you create new elements in the DOM using JavaScript?


2. What is the purpose of the document.createElement() method?
3. Can you provide an example of dynamically creating and appending elements to the
DOM?
4. How do you set attributes and properties on newly created elements?

appendChild:

1. What is the purpose of the appendChild() method in JavaScript?


2. How do you use appendChild() to add elements to the DOM?
3. Can you explain the difference between appendChild() and insertBefore()?
4. Provide a use case where you would use appendChild() to manipulate the DOM.

You might also like