JOIN ADRE 2.0 Telegram Group

JavaScript Questions & Answers – Expressions and Operators | JavaScript MCCs

Questions
1 What will be the output of the following JavaScript code?
var string1 = ”123”;
var intvalue = 123;
alert( string1 + intvalue );
A 123246
B 246
C 123123
D Exception

Answer: 123123
2 A function definition expression can be called as __________
A Function prototype
B Function literal
C Function calling
D Function declaration

Answer: Function literal
Advertisement
Article and Schedule Quiz Start Test!

DOWNLOAD CURRENT AFFAIRS PDF FROM APP

3 The property of a primary expression is ____________
A stand-alone expressions
B basic expressions containing all necessary functions
C contains variable references alone
B contains only keywords

Answer: stand-alone expressions
4

Consider the following JavaScript statements.

var text = "testing: 1, 2, 3"; // Sample text

var pattern = /\d+/g // Matches all instances of one or more digits

In order to check if the pattern matches with the string “text”, the statement is ____________

A text==pattern
B text.equals(pattern)
C text.test(pattern)
D pattern.test(text)

Answer: pattern.test(text)
5 The expression of calling (or executing) a function or method in JavaScript is called ________
A Primary expression
B Functional expression
C Invocation expression
B Property Access Expression

Answer: Invocation expression
6 What kind of expression is “new Point(2,3)”?
A Primary Expression
B Object Creation Expression
C Invocation Expression
D Constructor Calling Expression

Answer: Object Creation Expression
7 Which of the operator is used to test if a particular property exists or not?
A in
B exist
C within
D exists

Answer: in
8 Among the following, which one is a ternary operator?
A +
B :
C
D ?:

Answer: ?:
9 “An expression that can legally appear on the left side of an assignment expression.” is a well known explanation for variables, properties of objects, and elements of arrays. They are called ___________
A Properties
B Prototypes
C Lvalue
D Definition

Answer: Lvalue
10 What will be the equivalent output of the following JavaScript code snippet?
x = ~-y;
w = x = y = z;
q = a?b:c?d:e?f:g;
A
x = ~(-y); w = (x = (y = z));
q = a?b:(c?d:(e?f:g));
B
x = a?b:(c?d:(e?f:g));
q = ~(-y); w = (x = (y = z));
C
x = (x = (y = z));w = ~(-y);
q = a?b:(c?d:(e?f:g));
D
x = ~(-y); w = (x = (y = z)); 
q = (c?d:(e?f:g));

Answer:
x = ~(-y); w = (x = (y = z));
q = a?b:(c?d:(e?f:g));
11 What will be the output of the following JavaScript code?
function output(option)
{
	return (option ?  “yes” :  “no”);
}
	bool ans=true;
console.log(output(ans));
A Yes
B No
C Runtime error
B Compilation error

Answer: Yes
12 What will be the output of the following JavaScript code?
var  obj=
{
	length:20,
	height:35,
}
if (‘breadth' in obj === false)
{
  	obj.breadth = 12;
} 
console.log(obj.breadth);
A 20
B 12
C undefined
D error

Answer: 12
13 What will be the output of the following JavaScript code?
function height()
{
   var  height = 123.56;
    var type = (height>=190) ? "tall" : "short";

return type; }
A 123.56
B 190
C tall
D short

Answer: short
14 What will be the output of the following JavaScript code?
string  a = ”hi”;
string  b =”there”;
alert(a+b);
A hi
B there
C hithere
D undefined

Answer: hithere
15 What will be the output of the following JavaScript code?
function output(object)
{
	var place=object ? object.place : “Italy”;
	return “clean:”+ place;

} console.log(output({place:India}));
A clean:India
B clean:Italy
C error
D undefined

Answer: clean:India

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