Get 20% off on all courses. Enroll now!
ANS : (d) Both var and let can be used to declare variables in JavaScript.
ANS : (d) All of the above are valid data types in JavaScript.
ANS : (a) The correct way to create a function in JavaScript is function myFunction() {}.
console.log(typeof null);
ANS : (a) The output will be "object" because of a historical bug in JavaScript.
ANS : (a) The correct way to parse a JSON string in JavaScript is JSON.parse().
ANS : (c) Both {} and new Object() can be used to create an object in JavaScript.
ANS : (d) All of the above are popular JavaScript frameworks.
console.log(0.1 + 0.2 === 0.3);
ANS : (b) The output will be false due to floating-point precision issues.
ANS : (a) The correct method to prevent the default action of an event is event.preventDefault();.
ANS : (b) The `this` keyword refers to the current object in the context of which it is used.
ANS : (d) All of the above methods can be used to convert a string to a number in JavaScript.
console.log(1 + '1');
ANS : (b) The output will be "11" because of type coercion in JavaScript.
ANS : (a) The setTimeout() function is used to delay the execution of a function.
ANS : (c) Both try-catch and throw are used to handle exceptions in JavaScript.
console.log(2 + '2');
ANS : (b) The output will be "22" due to type coercion in JavaScript.
ANS : (c) Both new Array() and [] can be used to create an array in JavaScript.
console.log(typeof NaN);
ANS : (a) The output will be "number" because NaN is considered a number type in JavaScript.
ANS : (a) Curly braces {} are used to define a block of code in JavaScript.
ANS : (a) The `window.onload` event is used to execute code when the DOM is fully loaded.
ANS : (a) The = operator is used to assign values.
ANS : (a) // is used for single-line comments in JavaScript.
ANS : (c) The correct way is <script src="script.js">.
ANS : (c) A JavaScript function is created using the function keyword.
ANS : (d) All of the above keywords are used to declare variables.
ANS : (a) Math.round() is used to round numbers to the nearest integer.
ANS : (d) JavaScript supports Number, String, Boolean, and other types.
ANS : (b) You call a function by using its name followed by parentheses.
ANS : (b) The break statement exits a loop.
ANS : (a) push() adds elements to the end of an array.
ANS : (c) JavaScript uses if (condition) syntax.
ANS : (b) pop() removes the last element of an array.
ANS : (a) parseInt() converts strings to integers.
ANS : (c) There is no "loop" statement in JavaScript.
ANS : (c) Due to a bug in JavaScript, `typeof null` returns "object".
ANS : (b) JavaScript performs string concatenation when a number is added to a string.
ANS : (d) JavaScript supports single-line (//) and multi-line (/* */) comments.
ANS : (a) The = operator is used for assignment.
ANS : (c) `const` is used to declare constants in JavaScript.
ANS : (c) The correct way is <script src="xxx.js">
ANS : (b) `isNaN()` checks if the value is NaN (Not-a-Number).
ANS : (a) The `window` object is at the top of the scope chain in browsers.
ANS : (a) `console.log()` prints output to the browser console.
ANS : (b) Arrays in JavaScript are of type object.
ANS : (b) `onclick` is triggered when an element is clicked.
ANS : (b) `Boolean(0)` returns false.
ANS : (b) JSON.parse() is used to convert JSON strings into JavaScript objects.
ANS : (c) The `.length` property returns the number of characters in a string.
ANS : (c) === checks for both value and type equality.
ANS : (c) `addEventListener()` attaches an event handler to an element.