JOIN ADRE 2.0 Telegram Group

JavaScript Questions & Answers – Defining and Invoking Functions | JavaScript MCQs

Questions
1 The function definitions in JavaScript begins with _____________
A Identifier and Parentheses
B Return type and Identifier
C Return type, Function keyword, Identifier and Parentheses
D Identifier and Return type

Answer: Return type, Function keyword, Identifier and Parentheses
2 What will be the output of the following JavaScript code?
function printprops(o)
	{
    for(var p in o)
     	console.log(p + ": " + o[p] + "\n");
	}
A Prints the contents of each property of o
B Returns undefined
C Prints only one property
D Prints the address of elements

Answer: Returns undefined
Advertisement
Article and Schedule Quiz Start Test!

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

3 When does the function name become optional in JavaScript?
A When the function is defined as a looping statement
B When the function is defined as expressions
C When the function is predefined
D when the function is called

Answer: When the function is defined as expressions
4 What is the purpose of a return statement in a function?
A Returns the value and continues executing rest of the statements, if any
B Returns the value and stops the program
C Returns the value and stops executing the function
D Stops executing the function and returns the value

Answer: Stops executing the function and returns the value
5 What will happen if a return statement does not have an associated expression?
A It returns the value 0
B It will throw an exception
C It returns the undefined value
D It will throw an error

Answer: It returns the undefined value
6 A function with no return value is called ___________
A Procedures
B Method
C Static function
D Dynamic function

Answer: Procedures
7 The function stops its execution when it encounters?
A continue statement
B break statement
C goto statement
D return statement

Answer: return statement
8 Which keyword is used to define the function in javascript?
A void
B int
C function
D main

Answer: function
9 Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?
A o(x,y);
B o.m(x) && o.m(y);
C m(x,y);
D o.m(x,y);

Answer: o.m(x,y);
10 What will be the equivalent code of the following JavaScript code?

o.m(x,y);

A o.m(x) && o.m(y);
B o[“m”](x,y);
C o(m)[“x”,”y”];
D o.m(x && y);

Answer: o[“m”](x,y);
11 What will be the output of the following JavaScript code?
function info()
	{ 
    int a=1;
   int b=2;
    return a*b;
	}  
document.write(info());
A 1
B 2
C 3
D error

Answer: 2
12 What will be the output of the following JavaScript code?
var arr = [7, 5, 9, 1]; 
var value = Math.max.apply(null, arr);
document.writeln(value);
A 7
B 5
C 1
D 9

Answer: 9
13 What will be the output of the following JavaScript code?
var person =
{ 
      name: “Rahul”,
      getName: function()
      {  
         nreturn this.name; 
      }  
}
var unboundName = person.getName;  
var boundName = unboundName.bind(person);
document.writeln(boundName());
A runtime error;
B compilation error
C Rahul
D undefined

Answer: Rahul
14 What will be the output of the following JavaScript code?
function code(id,name)
{
  		this.id = id;
  		this.name = name;
}
function pcode(id,name)
{
 		code.call(this,id,name);
}
document.writeln(new pcode(101,"vivek").id);
A vivek
B 101
C Runtime error
D Compilation error

Answer: 101
15 What will be the output of the following JavaScript code?
var pow=new Function("num1","num2","return Math.pow(num1,num2)");
     document.writeln(pow(2,3));
A 2
B 3
C 8
D error

Answer: 8

ADRE 2.0 FULL LENGTH MOCK TEST

Take Mock Tests

Missiles Mock Test Start Test!
SSC MTS Mock Test Start Test
IBPS CLERK MOCK TEST Start Test
SSC MTS 2022 JULY 26 Shift 1 (ENGLISH) Start Test!
SSC GD Previous Year Paper 2021 Nov 17 Shift - I (Hindi) Start Test!
SSC CGL Tier - 1 PYP 2022 April 21 Shift- 1 (ENGLISH) Start Test!
MPSC PAPER I MOCK TEST 1 (ENGLISH) Start Test!
IB Security Assistant Mock test 1 (english) Start Test!
UP POLICE CONSTABLE MOCK TEST 1 Start Test!
DELHI POLICE CONSTABLE MOCK TEST 1 (HINDI) Start Test!
Advertisement
Assam Direct Recruitment Test Series

Latest Test Series

ssc cgl test series

SSC CGL

Start Test 1000+ Tests Latest patternView Course
delhi policesi test series

DELHI POLICE SI

Start Test 1000+ Tests Latest patternView Course
west bengal psc test series

WEST BENGAL PSC

Start Test 1000+ Tests Latest patternView Course
cisf head constable test series

CISF CONSTABLE

Start Test 1000+ Tests Latest patternView Course
Junior Associate of the Indian Institute of Bankers(JAIIB) test series

JAIIB

Start Test 30 Full Length Tests View Course
adre 2024 test series

ADRE 2024

Start Test 25000+ QUESTIONS SOLUTIONSView Course
RRB RRC GROUP D test series

RRB RRC GROUP D

Start Test 15000+ QUESTIONS Latest patternView Course
UP POLICE SI test series

UP POLICE SI

Start Test 16000+ QUESTIONS Latest patternView Course
CLICK HERE TO VIEW ALL COURSES