JavaScript

How do you check if a variable is an array in JavaScript?

How do you check if a variable is an array in JavaScript? a) Array.isArray(variable) b) variable.isArray() c) typeof variable === “array” d) variable instanceof Array Answer: a) Array.isArray(variable) Explanation: The method Array.isArray() is used to determine whether a variable is an array. It returns true if the variable is an array, and false otherwise. Example:

How do you check if a variable is an array in JavaScript? Read More »

What is the output of the following code: console.log(typeof null);?

What is the output of the following code: console.log(typeof null);? a) “object” b) “null” c) “undefined” d) “boolean” Answer: a) “object” Explanation: In JavaScript, the typeof operator returns “object” when applied to null. This is considered a quirk in JavaScript, as null is generally treated as a separate data type. Example: console.log(typeof null); // Output:

What is the output of the following code: console.log(typeof null);? Read More »

What is the output of the following code: console.log(typeof 42);?

What is the output of the following code: console.log(typeof 42);? a) “number” b) “string” c) “boolean” d) “undefined” Answer: a) “number” Explanation: The typeof operator is used to determine the data type of a given variable or value in JavaScript. In this case, 42 is a number, so the output is “number”. Example: console.log(typeof 42);

What is the output of the following code: console.log(typeof 42);? Read More »

Which of the following is used to output data to the browser console in JavaScript?

Which of the following is used to output data to the browser console in JavaScript? a) console.output() b) console.log() c) output.console() d) browser.log() Answer: b) console.log() Explanation: To output data to the browser’s console, you use the console.log() method in JavaScript. This is useful for debugging and displaying information during development. Example: console.log("Hello, World!"); Reference:

Which of the following is used to output data to the browser console in JavaScript? Read More »

What is JavaScript?

What is JavaScript? a) A programming language for web development b) A type of hardware c) A database language d) A styling language Answer: a) A programming language for web development Explanation: JavaScript is a popular programming language used primarily for web development. It allows developers to create dynamic content and interactive elements in web

What is JavaScript? Read More »

Scroll to Top