JavaScript Mid
What is ArrayBuffer?
Select the correct answer
ArrayBuffer is used to style HTML elements.
ArrayBuffer is a server-side technology.
ArrayBuffer is used to manage browser cookies.
ArrayBuffer is a type of object used to represent a fixed-length raw binary data buffer.
What is polyfill?
Select the correct answer
A polyfill is used to style HTML elements.
A polyfill is used to manage browser cookies.
A polyfill is code that provides modern functionality in older environments that do not natively support it.
A polyfill is a server-side technology.
What are modules?
Select the correct answer
Modules are reusable pieces of code that can be imported and exported.
Modules are used to style HTML elements.
Modules are used to manage browser cookies.
Modules are server-side components.
What is Object.freeze?
Select the correct answer
Object.freeze styles HTML elements.
Object.freeze prevents modifications to an object.
Object.freeze duplicates an object.
Object.freeze allows modifications to an object.
What is type coercion?
Select the correct answer
Type coercion is the process of declaring variables.
Type coercion is the manual conversion of values from one type to another.
Type coercion is the automatic conversion of values from one type to another.
Type coercion is used for styling HTML elements.
Explain the spread/rest operator (...) in ES6.
Select the correct answer
The spread operator (...) condenses multiple elements into an array, and the rest operator (...) expands iterable values.
The spread operator (...) expands iterable values, and the rest operator (...) condenses multiple elements into an array.
The spread operator (...) is used only for objects, and the rest operator (...) is used only for arrays.
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
ES6 is the same as ES5 with no new features.
ES5 introduced features like arrow functions, classes, and template literals.
ES6 is used for backend development only.
ES6 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
To determine if two values are the same, use Object.equal method.
To determine if two values are the same, use Object.is method.
To determine if two values are the same, use Object.copy method.
To determine if two values are the same, use Object.compare method.
What is the Event Loop in JavaScript, and how does it work?
Select the correct answer
The Event Loop in JavaScript manages the execution of asynchronous code.
The Event Loop in JavaScript compiles the code.
The Event Loop in JavaScript styles HTML elements.
The Event Loop in JavaScript manages browser cookies.
What is optional chaining?
Select the correct answer
Optional chaining is used to style HTML elements.
Optional chaining is a feature that allows safe access to nested object properties.
Optional chaining is used to import modules.
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
Cross-Origin Resource Sharing (CORS) policy allows restricted resources on a web page to be requested from another domain.
Cross-Origin Resource Sharing (CORS) policy is a server-side technology.
Cross-Origin Resource Sharing (CORS) policy is used to style web pages.
Cross-Origin Resource Sharing (CORS) policy is used to compile JavaScript code.
What is Cross-Site Scripting (XSS) in web security, and how can you prevent it?
Select the correct answer
Cross-Site Scripting (XSS) is a server-side technology.
Cross-Site Scripting (XSS) is used to manage browser cookies.
Cross-Site Scripting (XSS) is a method to style web pages.
Cross-Site Scripting (XSS) is a security vulnerability that allows attackers to inject malicious scripts into web pages.
What is a pure function?
Select the correct answer
A pure function is a function that has no side effects and returns the same output for the same input.
A pure function is a function that only works with strings.
A pure function is a function that always returns a promise.
A pure function is a function that can only be used in synchronous code.
What is a higher-order function?
Select the correct answer
A higher-order function is a function that always returns a promise.
A higher-order function is a function that is always asynchronous.
A higher-order function is a function that only works with arrays.
A higher-order function is a function that takes another function as an argument or returns a function.
What is ECMAScript?
Select the correct answer
ECMAScript is a server-side language.
ECMAScript is a CSS framework.
ECMAScript is the standard on which JavaScript is based.
ECMAScript is a JavaScript library.
What is AJAX, and how does it work in JavaScript?
Select the correct answer
AJAX allows web pages to be updated asynchronously by exchanging data with a server.
AJAX is a server-side technology.
AJAX is used to compile JavaScript code.
AJAX is used to style web pages.
What is the difference between double (==) and triple (===) equals in JavaScript?
Select the correct answer
Double equals (==) checks for value equality, triple equals (===) checks for value and type equality.
Double equals (==) checks for value and type equality, triple equals (===) checks for value equality.
Double equals (==) and triple equals (===) are the same.
Double equals (==) checks for object reference equality, triple equals (===) checks for array equality.
Is JavaScript pass by reference or pass by value?
Select the correct answer
JavaScript is pass by value for primitives and pass by reference for objects.
JavaScript is pass by reference for primitives and pass by value for objects.
JavaScript is always pass by value.
JavaScript is always pass by reference.
What is the difference between the client side and server side?
Select the correct answer
Client side refers to operations on the user's browser, server side refers to operations on the server.
Client side refers to server operations, server side refers to browser operations.
Client side and server side are the same.
Client side and server side do not perform operations.
What is NaN?
Select the correct answer
NaN stands for Number-and-Null.
NaN stands for Not-a-Number, representing a valid number.
NaN stands for Null-and-Number.
NaN stands for Not-a-Number, representing an invalid number.
What is the difference between null and undefined?
Select the correct answer
null represents the intentional absence of value, undefined represents the uninitialized state.
null represents the uninitialized state, undefined represents the intentional absence of value.
null and undefined are the same.
null and undefined are used to declare variables.
What is the difference between a shallow and a deep copy?
Select the correct answer
A shallow copy duplicates only the top-level properties, a deep copy duplicates all nested properties.
Shallow copy and deep copy do not duplicate properties.
A shallow copy duplicates all nested properties, a deep copy duplicates only the top-level properties.
Shallow copy and deep copy are the same.
What are template literals (template strings) in ES6?
Select the correct answer
Template literals are used to import modules.
Template literals are string literals allowing embedded expressions.
Template literals are used to style HTML elements.
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
A package manager like npm or yarn compiles JavaScript code.
A package manager like npm or yarn styles HTML elements.
A package manager like npm or yarn manages browser cookies.
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
Event bubbling and event capturing do not propagate events.
Event bubbling and event capturing are the same.
Event capturing propagates events from child to parent, event bubbling from parent to child.
Event bubbling propagates events from child to parent, event capturing from parent to child.
How to prevent event bubbling?
Select the correct answer
To prevent event bubbling, use the preventDefault method.
To prevent event bubbling, use the stopImmediatePropagation method.
To prevent event bubbling, use the stopPropagation method.
To prevent event bubbling, use the addEventListener method.
Explain event bubbling in JavaScript?
Select the correct answer
Event bubbling is used to prevent event default behavior.
Event bubbling stops the event from being propagated.
Event bubbling is the event propagation from child to parent elements.
Event bubbling is the event propagation from parent to child elements.
Explain Promise.all.
Select the correct answer
Promise.all is used to handle synchronous operations.
Promise.all takes an array of promises and returns a single promise.
Promise.all executes promises in sequence.
Promise.all returns the first resolved promise.
What is callback hell?
Select the correct answer
Callback hell is when callbacks are used to manage CSS styles.
Callback hell refers to the situation where callbacks are nested within other callbacks.
Callback hell occurs when callbacks are used in synchronous code.
Callback hell is when callbacks are executed in parallel.
What are Promises?
Select the correct answer
Promises are used to handle asynchronous operations in JavaScript.
Promises are used to manage CSS styles.
Promises are used to perform mathematical operations.
Promises are used to declare variables.
What are callback functions?
Select the correct answer
Callback functions are used to style HTML elements.
Callback functions are only used in synchronous code.
Callback functions are functions that call themselves recursively.
Callback functions are functions passed into another function as an argument.
Explain synchronous vs asynchronous programming.
Select the correct answer
Synchronous programming is only used in frontend development, while asynchronous programming is used in backend development.
Synchronous programming allows tasks to run concurrently, while asynchronous programming executes tasks sequentially.
Synchronous programming executes tasks sequentially, while asynchronous programming allows tasks to run concurrently.
Synchronous programming is used for styling, while asynchronous programming is used for scripting.
What is the difference between Session Storage and Local Storage?
Select the correct answer
Session Storage data is cleared when the page session ends, Local Storage persists.
Local Storage data is cleared when the page session ends, Session Storage persists.
Session Storage can store more data than Local Storage.
Local Storage can only store strings, Session Storage can store objects.
Explain the concept of closures in JavaScript
Select the correct answer
Closures allow functions to access variables from an outer function scope.
Closures are used to style HTML elements.
Closures are used to import modules.
Closures prevent functions from accessing variables from an outer function scope.
What are the main differences between arrow and regular functions?
Select the correct answer
Arrow functions cannot be assigned to variables.
Arrow functions cannot accept arguments.
Arrow functions are always synchronous.
Arrow functions do not have their own this context.
What is the difference between function declaration and function expression JavaScript?
Select the correct answer
Both function declarations and function expressions are hoisted.
Neither function declarations nor function expressions are hoisted.
Function declarations are hoisted, function expressions are not.
Function expressions are hoisted, function declarations are not.