JavaScript MCQs with answers Page - 39

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. byte is reserved word in Javascript?

  • (A) Yes
  • (B) No
  • (C) Can be yes or no
  • (D) Can not say

A

Admin • 833K Points
Coach

Q. 123test is an valid variable name?

  • (A) True
  • (B) False
  • (C) Can be true or false
  • (D) Can not say

A

Admin • 833K Points
Coach

Q. Consider the JavaScript code:
Identify the value that will be displayed in alert box at line 5?

Code:
function lfc(myname){
console.log(10+"lfc" +12);
}
res=lfc(10);
console.log(res); //line 5
  • (A) 10
  • (B) 10lfc12
  • (C) 10lfc
  • (D) undefined

A

Admin • 833K Points
Coach

Q. Consider the JavaScript code:
Choose the correct code to be inserted at line 4 in order to invoke the function.

Code:
thisfun=function lfc(x){
console.log(x*x);
}
// line 4
  • (A) thisfun(10)
  • (B) lfc(10)
  • (C) function thisfun(10)
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. What will be the output of the below code?

Code:
function password(pass) {
for (i = 0; i < pass.length; i++) {
}
}

function name(pname) {
console.log("The value of i is "+i);
for (i = 0; i < pname.length; i++) {
}
}

password("54321");
name("John");
  • (A) 0
  • (B) 5
  • (C) undefined
  • (D) error

A

Admin • 833K Points
Coach

Q. What will be the output of the below code?

Code:
let chaval= (p)=>p+2;
console.log(chaval(2));
  • (A) 4
  • (B) 22
  • (C) Error: changeVal is not a function
  • (D) undefined

A

Admin • 833K Points
Coach

Q. what will be the output of the below code?

Code:
num1=5;
function cal() {
num1=10;
num2=5;
num3=num2*num1;
console.log(num3);
}
cal();
  • (A) 25
  • (B) 50
  • (C) 100
  • (D) Error cannot have more than one variable with same name

A

Admin • 833K Points
Coach

Q. Functions are invoked as functions or as methods with an __________.

  • (A) invocation statement
  • (B) invocation expression
  • (C) invocation function
  • (D) invocation method

A

Admin • 833K Points
Coach

Q. ........ functions need not allow invocations with zero arguments.

  • (A) zero
  • (B) strict
  • (C) empty
  • (D) varargs

A

Admin • 833K Points
Coach

Q. When you invoke the........ method on a function f and pass an object o, the method returns a new function.

  • (A) apply()
  • (B) call()
  • (C) bind()
  • (D) string()

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ