JavaScript Expert

1 / 54

How are heaps related to JavaScript?

Select the correct answer

1

Heaps in JavaScript are related to memory allocation.

2

Heaps in JavaScript are used to style HTML elements.

3

Heaps in JavaScript are a type of function.

4

Heaps in JavaScript are used to manage browser cookies.

What is a generator function?

Select the correct answer

1

A generator function is a function that can only be used in synchronous code.

2

A generator function is a function that always returns a promise.

3

A generator function is a function that only works with arrays.

4

A generator function is a function that can pause and resume its execution.

What is the difference between reflow and repaint?

Select the correct answer

1

Repaint is the process of calculating the layout of a webpage, while reflow is the process of updating the visual appearance.

2

Reflow and repaint are used only in backend development.

3

Reflow is the process of calculating the layout of a webpage, while repaint is the process of updating the visual appearance.

4

Reflow and repaint are the same process.

Why is JavaScript treated as single-threaded?

Select the correct answer

1

JavaScript is treated as single-threaded because it can only run on single-core processors.

2

JavaScript is treated as single-threaded because it executes one piece of code at a time.

3

JavaScript is treated as single-threaded because it is used only for styling.

4

JavaScript is treated as single-threaded because it can only be used on servers.

What Is Obfuscation in JavaScript?

Select the correct answer

1

Obfuscation in JavaScript is the practice of making code difficult to understand.

2

Obfuscation in JavaScript is the practice of making code easier to read.

3

Obfuscation in JavaScript is the practice of compiling code.

4

Obfuscation in JavaScript is the practice of styling HTML elements.

What is a Temporal Dead Zone?

Select the correct answer

1

A Temporal Dead Zone is the time between entering a scope and when the variable is declared.

2

A Temporal Dead Zone is the time between variable declaration and variable assignment.

3

A Temporal Dead Zone is the time between scope exit and variable declaration.

4

A Temporal Dead Zone is the time between variable assignment and variable declaration.

Explain hoisting.

Select the correct answer

1

Hoisting is a server-side technique.

2

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope.

3

Hoisting is a JavaScript mechanism for styling HTML elements.

4

Hoisting is a JavaScript mechanism for managing browser cookies.

What is event delegation in JavaScript?

Select the correct answer

1

Event delegation is a technique for handling events where a single event listener is added to a parent element.

2

Event delegation is a method to stop event propagation.

3

Event delegation is used to style HTML elements.

4

Event delegation is a server-side technique.

What is ArrayBuffer?

Select the correct answer

1

ArrayBuffer is used to style HTML elements.

2

ArrayBuffer is a server-side technology.

3

ArrayBuffer is used to manage browser cookies.

4

ArrayBuffer is a type of object used to represent a fixed-length raw binary data buffer.

What is polyfill?

Select the correct answer

1

A polyfill is code that provides modern functionality in older environments that do not natively support it.

2

A polyfill is used to manage browser cookies.

3

A polyfill is used to style HTML elements.

4

A polyfill is a server-side technology.

What are modules?

Select the correct answer

1

Modules are reusable pieces of code that can be imported and exported.

2

Modules are used to style HTML elements.

3

Modules are server-side components.

4

Modules are used to manage browser cookies.

What is Object.freeze?

Select the correct answer

1

Object.freeze styles HTML elements.

2

Object.freeze prevents modifications to an object.

3

Object.freeze duplicates an object.

4

Object.freeze allows modifications to an object.

What is type coercion?

Select the correct answer

1

Type coercion is used for styling HTML elements.

2

Type coercion is the process of declaring variables.

3

Type coercion is the manual conversion of values from one type to another.

4

Type coercion is the automatic conversion of values from one type to another.

Explain the spread/rest operator (...) in ES6.

Select the correct answer

1

The spread operator (...) is used only for objects, and the rest operator (...) is used only for arrays.

2

The spread operator (...) condenses multiple elements into an array, and the rest operator (...) expands iterable values.

3

The spread operator (...) expands iterable values, and the rest operator (...) condenses multiple elements into an array.

4

The spread operator (...) and the rest operator (...) are used for styling HTML elements.

What are the difference between es5 and es6?

Select the correct answer

1

ES6 is used for backend development only.

2

ES6 introduced features like arrow functions, classes, and template literals.

3

ES6 is the same as ES5 with no new features.

4

ES5 introduced features like arrow functions, classes, and template literals.

How do you determine two values same or not using object in JavaScript?

Select the correct answer

1

To determine if two values are the same, use Object.equal method.

2

To determine if two values are the same, use Object.compare method.

3

To determine if two values are the same, use Object.is method.

4

To determine if two values are the same, use Object.copy method.

What is the Event Loop in JavaScript, and how does it work?

Select the correct answer

1

The Event Loop in JavaScript manages browser cookies.

2

The Event Loop in JavaScript compiles the code.

3

The Event Loop in JavaScript manages the execution of asynchronous code.

4

The Event Loop in JavaScript styles HTML elements.

What is optional chaining?

Select the correct answer

1

Optional chaining is a feature that allows safe access to nested object properties.

2

Optional chaining is used to import modules.

3

Optional chaining is used to style HTML elements.

4

Optional chaining is used to declare variables.

What is a Cross-Origin Resource Sharing (CORS) policy, and how does it work?

Select the correct answer

1

Cross-Origin Resource Sharing (CORS) policy allows restricted resources on a web page to be requested from another domain.

2

Cross-Origin Resource Sharing (CORS) policy is a server-side technology.

3

Cross-Origin Resource Sharing (CORS) policy is used to compile JavaScript code.

4

Cross-Origin Resource Sharing (CORS) policy is used to style web pages.

What is Cross-Site Scripting (XSS) in web security, and how can you prevent it?

Select the correct answer

1

Cross-Site Scripting (XSS) is a security vulnerability that allows attackers to inject malicious scripts into web pages.

2

Cross-Site Scripting (XSS) is a method to style web pages.

3

Cross-Site Scripting (XSS) is a server-side technology.

4

Cross-Site Scripting (XSS) is used to manage browser cookies.

What is a pure function?

Select the correct answer

1

A pure function is a function that has no side effects and returns the same output for the same input.

2

A pure function is a function that always returns a promise.

3

A pure function is a function that can only be used in synchronous code.

4

A pure function is a function that only works with strings.

What is a higher-order function?

Select the correct answer

1

A higher-order function is a function that always returns a promise.

2

A higher-order function is a function that takes another function as an argument or returns a function.

3

A higher-order function is a function that is always asynchronous.

4

A higher-order function is a function that only works with arrays.

What is ECMAScript?

Select the correct answer

1

ECMAScript is a server-side language.

2

ECMAScript is a CSS framework.

3

ECMAScript is a JavaScript library.

4

ECMAScript is the standard on which JavaScript is based.

What is AJAX, and how does it work in JavaScript?

Select the correct answer

1

AJAX is used to style web pages.

2

AJAX allows web pages to be updated asynchronously by exchanging data with a server.

3

AJAX is used to compile JavaScript code.

4

AJAX is a server-side technology.

What is the difference between double (==) and triple (===) equals in JavaScript?

Select the correct answer

1

Double equals (==) checks for value equality, triple equals (===) checks for value and type equality.

2

Double equals (==) checks for object reference equality, triple equals (===) checks for array equality.

3

Double equals (==) checks for value and type equality, triple equals (===) checks for value equality.

4

Double equals (==) and triple equals (===) are the same.

Is JavaScript pass by reference or pass by value?

Select the correct answer

1

JavaScript is pass by value for primitives and pass by reference for objects.

2

JavaScript is always pass by reference.

3

JavaScript is pass by reference for primitives and pass by value for objects.

4

JavaScript is always pass by value.

What is the difference between the client side and server side?

Select the correct answer

1

Client side refers to server operations, server side refers to browser operations.

2

Client side and server side do not perform operations.

3

Client side refers to operations on the user's browser, server side refers to operations on the server.

4

Client side and server side are the same.

What is NaN?

Select the correct answer

1

NaN stands for Null-and-Number.

2

NaN stands for Not-a-Number, representing a valid number.

3

NaN stands for Not-a-Number, representing an invalid number.

4

NaN stands for Number-and-Null.

What is the difference between null and undefined?

Select the correct answer

1

null and undefined are the same.

2

null represents the uninitialized state, undefined represents the intentional absence of value.

3

null and undefined are used to declare variables.

4

null represents the intentional absence of value, undefined represents the uninitialized state.

What is the difference between a shallow and a deep copy?

Select the correct answer

1

Shallow copy and deep copy do not duplicate properties.

2

Shallow copy and deep copy are the same.

3

A shallow copy duplicates all nested properties, a deep copy duplicates only the top-level properties.

4

A shallow copy duplicates only the top-level properties, a deep copy duplicates all nested properties.

What are template literals (template strings) in ES6?

Select the correct answer

1

Template literals are used to style HTML elements.

2

Template literals are string literals allowing embedded expressions.

3

Template literals are used to import modules.

4

Template literals are used to declare variables.

What is the role of a package manager like npm or yarn in JavaScript development?

Select the correct answer

1

A package manager like npm or yarn manages browser cookies.

2

A package manager like npm or yarn styles HTML elements.

3

A package manager like npm or yarn compiles JavaScript code.

4

A package manager like npm or yarn manages dependencies and packages in JavaScript.

What is the difference between event bubbling and event capturing?

Select the correct answer

1

Event bubbling and event capturing are the same.

2

Event bubbling propagates events from child to parent, event capturing from parent to child.

3

Event bubbling and event capturing do not propagate events.

4

Event capturing propagates events from child to parent, event bubbling from parent to child.

How to prevent event bubbling?

Select the correct answer

1

To prevent event bubbling, use the stopPropagation method.

2

To prevent event bubbling, use the preventDefault method.

3

To prevent event bubbling, use the stopImmediatePropagation method.

4

To prevent event bubbling, use the addEventListener method.

Explain event bubbling in JavaScript?

Select the correct answer

1

Event bubbling is the event propagation from child to parent elements.

2

Event bubbling is the event propagation from parent to child elements.

3

Event bubbling stops the event from being propagated.

4

Event bubbling is used to prevent event default behavior.

Explain Promise.all.

Select the correct answer

1

Promise.all takes an array of promises and returns a single promise.

2

Promise.all is used to handle synchronous operations.

3

Promise.all executes promises in sequence.

4

Promise.all returns the first resolved promise.

What is callback hell?

Select the correct answer

1

Callback hell refers to the situation where callbacks are nested within other callbacks.

2

Callback hell occurs when callbacks are used in synchronous code.

3

Callback hell is when callbacks are executed in parallel.

4

Callback hell is when callbacks are used to manage CSS styles.

What are Promises?

Select the correct answer

1

Promises are used to declare variables.

2

Promises are used to perform mathematical operations.

3

Promises are used to manage CSS styles.

4

Promises are used to handle asynchronous operations in JavaScript.

What are callback functions?

Select the correct answer

1

Callback functions are functions that call themselves recursively.

2

Callback functions are only used in synchronous code.

3

Callback functions are used to style HTML elements.

4

Callback functions are functions passed into another function as an argument.

Explain synchronous vs asynchronous programming.

Select the correct answer

1

Synchronous programming is used for styling, while asynchronous programming is used for scripting.

2

Synchronous programming executes tasks sequentially, while asynchronous programming allows tasks to run concurrently.

3

Synchronous programming allows tasks to run concurrently, while asynchronous programming executes tasks sequentially.

4

Synchronous programming is only used in frontend development, while asynchronous programming is used in backend development.

What is the difference between Session Storage and Local Storage?

Select the correct answer

1

Session Storage data is cleared when the page session ends, Local Storage persists.

2

Local Storage data is cleared when the page session ends, Session Storage persists.

3

Session Storage can store more data than Local Storage.

4

Local Storage can only store strings, Session Storage can store objects.

Explain the concept of closures in JavaScript

Select the correct answer

1

Closures allow functions to access variables from an outer function scope.

2

Closures prevent functions from accessing variables from an outer function scope.

3

Closures are used to import modules.

4

Closures are used to style HTML elements.

What are the main differences between arrow and regular functions?

Select the correct answer

1

Arrow functions do not have their own this context.

2

Arrow functions are always synchronous.

3

Arrow functions cannot accept arguments.

4

Arrow functions cannot be assigned to variables.

What is the difference between function declaration and function expression JavaScript?

Select the correct answer

1

Both function declarations and function expressions are hoisted.

2

Function expressions are hoisted, function declarations are not.

3

Neither function declarations nor function expressions are hoisted.

4

Function declarations are hoisted, function expressions are not.

What are Imports and Exports in JavaScript?

Select the correct answer

1

Imports and Exports manage database connections.

2

Imports and Exports are used to style HTML elements.

3

Imports and Exports are used for defining CSS classes.

4

Imports and Exports allow modules to be used across different files.

What is the this keyword in JavaScript?

Select the correct answer

1

The this keyword is not used in JavaScript.

2

The this keyword refers to the object it belongs to.

3

The this keyword refers to the global object always.

4

The this keyword refers to the function's prototype.

What are the differences between var, let, and const?

Select the correct answer

1

var and let are block-scoped, const is function-scoped.

2

var is function-scoped, let and const are block-scoped.

3

var and const are block-scoped, let is function-scoped.

4

var is block-scoped, let and const are function-scoped.

What is the difference between the Document and Window in Javascript?

Select the correct answer

1

The Document object is for APIs, while the Window object is for HTML tags.

2

The Document object is for backend logic, while the Window object is for frontend logic.

3

The Document object is used for JavaScript code, while the Window object is used for CSS.

4

The Document object represents the HTML document, while the Window object represents the browser window.

Explain the window object.

Select the correct answer

1

The window object represents the browser's window.

2

The window object is used to style elements in CSS.

3

The window object represents the document's body.

4

The window object is a backend server component.

What is the DOM?

Select the correct answer

1

The DOM is a database management system.

2

The DOM is a JavaScript library.

3

The DOM is a styling language for web pages.

4

The DOM is a programming interface for HTML and XML documents.

What are the differences between JavaScript and TypeScript?

Select the correct answer

1

JavaScript and TypeScript are both compiled languages.

2

TypeScript is a completely different language from JavaScript.

3

TypeScript is a superset of JavaScript that adds static types.

4

JavaScript is a superset of TypeScript that adds dynamic types.

What is the difference between JavaScript and Java?

Select the correct answer

1

JavaScript is a scripting language, while Java is a programming language.

2

JavaScript is compiled, while Java is interpreted.

3

JavaScript is used for backend, while Java is used for frontend.

4

JavaScript and Java are the same in terms of syntax.

Is JavaScript a compiled or interpreted language?

Select the correct answer

1

JavaScript is an interpreted language.

2

JavaScript is both compiled and interpreted.

3

JavaScript is a compiled language.

4

JavaScript is neither compiled nor interpreted.

Is JavaScript a statically typed or a dynamically typed language?

Select the correct answer

1

JavaScript is a statically typed language.

2

JavaScript is a weakly typed language.

3

JavaScript is a dynamically typed language.

4

JavaScript is a strongly typed language.