JavaScript Operators

This section covers the questions for JavaScript Operators to clear all your concepts.

Last Updated :
Discuss
Comments

Question 1

Given the following code:

JavaScript
console.log(foo());
var foo = function() {
  return "Function Expression";
};
function foo() {
  return "Function Declaration";
}

What will be logged to the console?

  • "Function Expression"

  • "Function Declaration"

  • TypeError

  • ReferenceError

Question 2


console.log(foo());

var foo = function()

{ return "Function Expression"; };

function foo()

{ return "Function Declaration"; } 

What will be Logged to the console?

  • "Function Expression"

  • "Function Declaration"

  • Type Error

  • ReferenceError

Question 3

What will be the result of the following operation?

JavaScript
console.log(5 % 2);


  • 1

  • 2

  • 1.5

  • 5

Question 4

Which operator is used to compare both value and type?

  • ==

  • ===

  • !=

  • =

Question 5

Which of the following is a logical AND operator?


  • &&

  • ||

  • !

  • ^^

Question 6

Which of the following operators is used to assign a value to a variable?

  • ==

  • ===

  • =

  • :=

Question 7

Find the output of the following.

for (var i = 0; i < 3; i++) {

setTimeout(function() {

console.log(i); }, 100);

}

  • ReferenceError

  • 3 3 3

  • 0 1 2

  • undefined undefined undefined

Question 8

What is the output of this ternary operation?

JavaScript
const value = 10; 
console.log(value > 5 ? "Yes" : "No");


  • Yes

  • No

  • Error

  • Undefined

Question 9

Which operator is used for optional chaining in JavaScript?

  • .?

  • ?.

  • ::

  • ->

Question 10

What will the following code log?

JavaScript
console.log(5 == "5");


  • true

  • false

  • undefined

  • Error

There are 10 questions to complete.

Take a part in the ongoing discussion