Download as pdf or txt
Download as pdf or txt
You are on page 1of 56

Q1. What is the output for the below code?

document.write(“Hello world”)

Answer: Hello world displays in the browser.

Q2. What is the output for the below code?

console.log(“Welcome to edupoly”)

Answer:
Q3. What is the output for the below code?

var x=100;
console.log(x)

Answer: 100

Q4. What is the output for the below code?

var x=100;
console.log("x")

Answer: x

Q5. What is the output for the below code?

var v=14;
console.log(p);

Answer:
Q6. What is called for the below line?

var x;

This is called declaration

Q7. What is the output for the below code?

var r = 14;
console.log(r)

Answer: 14

var R = 14;
console.log(R)

Answer: 14

var r = 14;
console.log("r")

Answer: r
var R = 14;
console.log("R");

Answer: R

Q8. What is the output for the below code?

var x=10;
var y=20;
console.log(x+y);

Answer: 30

Q9. What is the output for the below code?

var a=10;
var b=20;
console.log("a"+"b");

Answer: ab

Q10. What is the output for the below code?

var a=10;
var b=20;
console.log("a+b");

Answer: a+b
Q11. What is the output for the below code?

var x="10";
var y=20;
console.log(x+y);

Answer: 1020
Q12. What is the output for the below code?

var x="10";
var y=20;
console.log("x"+y);

Answer: x20

Q13. What is the output for the below code?

var x="10";
var y=20;
console.log("x"+"y");

Answer: xy

Q14. What is the output for the below code?

var x="10";
var y=20;
console.log("x+y");

Answer: x+y

Q15. What is the output for the below code?

var x="10";
var y="20";
console.log(x+y);

Answer: 1020
Q16. What is the output for the below code?

var x="10";
var y="20";
console.log("x"+y);

Answer: x20

Q17. What is the output for the below code?

var x="10";
var y="20";
console.log(x+"y");

Answer: 10y

Q18. What is the output for the below code?

var x="10";
var y="20";
console.log("x"+"y");

Answer: xy

Q19. What is the output for the below code?

var x="10";
var y="20";
console.log("x+y");

Answer: x+y
Q20. What is the output for the below code?

var x="10";
var y="hello";
console.log(x+y);

Answer: 10hello

Q21. What is the output for the below code?

var x="10";
var y="hello";
console.log(x+"y");

Answer: 10y

Q22 . What is the output for the below code?

var x="10";
var y="hello";
console.log("x"+"y");

Answer: xy

Q23. What is the output for the below code?

var x="10";
var y="hello";
console.log("x+y");

Answer: x+y
Q24. What is the output for the below code?

var x=10;
var y="20";
console.log(x+y);

Answer: 1020

Q25. What is the output for the below code?

var x= 10;
var y="20";
console.log("x"+y);

Answer: x20

Q26. What is the output for the below code?

var x= 10;
var y="20";
console.log(x+"y");

Answer: 10y

Q27. What are the primitive data types are there in javascript?

Answer:

1. number
2. string
3. boolean
4. null
5. undefined
Q28. What is the output for the below code?

var x= 40;
var y= 20;
console.log(x - y);

Answer: 20

Q29. What is the output for the below code?

var x= 40;
var y= "20";
console.log(x - y);

Answer: 20

Q30. What is the output for the below code?

var x= "40";
var y= "20";
console.log(x - y);

Answer: 20

Q31. What is the output for the below code?

var x= "40";
var y= "20";
console.log("x"- y);

Answer: NaN
Q32. What is the output for the below code?

var x= "40";
var y= "20";
console.log("x"-"y");

Answer: NaN

Q33. What is the output for the below code?

var x= 10;
var y= 2;
console.log(x * y);

Answer: 20

Q34. What is the output for the below code?

var x= "10";
var y= 2;
console.log(x * y);

Answer: 20

Q35. What is the output for the below code?

var x= 10;
var y= "2";
console.log(x * y);

Answer: 20
Q36. What is the output for the below code?

var x= "10";
var y= "2";
console.log(x * y);

Answer: 20

Q37. What is the output for the below code?

var x= "10";
var y= "2";
console.log("x" * y);

Answer: NaN

Q38. What is the output for the below code?

var x= "10";
var y= "2";
console.log("x" * "y");

Answer: NaN

Q39. What is the output for the below code?

var x= 10;
var y= 2;
console.log(x / y);

Answer: 5
Q40. What is the output for the below code?

var x= "10";
var y= 2;
console.log(x / y);

Answer: 5

Q41. What is the output for the below code?

var x= 10;
var y= "2";
console.log(x / y);

Answer: 5

Q42. What is the output for the below code?

var x= "10";
var y= "2";
console.log(x / y);

Answer: 5

Q43. What is the output for the below code?

var x= "10";
var y= "2";
console.log("x" / y);

Answer: NaN
Q44. What is the output for the below code?

var x= 10;
var y= 2;
var z= 8
console.log(x + y + z);

Answer: 20

Q45. What is the output for the below code?

var x= 10;
var y= "2";
var z= 8
console.log(x + y + z);

Answer: 1028

Q46. What is the output for the below code?

var x= "10";
var y= 2;
var z= 8
console.log(x + y + z);

Answer: 1028

Q47. What is the output for the below code?

var x= 10;
var y= 2;
var z= "8"
console.log(x + y + z);
Answer: 128
Q48. What is the output for the below code?

var x= "10";
var y= 2;
var z= "8"
console.log(x + y + z);

Answer: 1028

Q49. What is the output for the below code?

var x= "10";
var y= 2;
var z= "8"
console.log("x" + y + z);

Answer: x28

Q50. What is the output for the below code?

var x= 10;
var y= 2;
var z= "8"
console.log("x" + y + z);

Answer: x28

Q51. What is the output for the below code?

var x= "10";
var y= 2;
var z= 8
console.log("x" + y + z);
Answer: x28
Q52. What is the output for the below code?

var x= "10";
var y= "hello";
var z= 8
console.log("x" + y + z);

Answer: xhello8

Q53. What is the output for the below code?

var x= "10";
var y= "hello";
var z= 8
console.log(x + y - z);

Answer: NaN

Q54. Output is the number which color it will print in the console?

var x= "10";
var y= "14";
var z= 8
var a= x + y - z;
console.log(a)

Answer: Output is number it will print in “blue” color

See the below image


Q55. Output is the string which color it will print in the console?

var m="10";
var n="hello";
var r=m+n;
console.log(r)
console.log(typeof(r));

Answer: output will print in “black” color


Q56. What is an operator in JavaScript?

Answer: An operator in JavaScript performs an operation on one or more


operands and produces a result.

Q57. What is the typeof operator used for?

Answer: The typeof operator is used to determine the data type of a


variable or expression.

Q58. What is the typeof null in JavaScript?

Answer: The typeof null gives"object".

Q59. What is the typeof undefined in JavaScript?

Answer: The typeof undefined gives “undefined”.

Q60. What are operands in JavaScript?

Answer: Operands are the values or variables operators act upon.

Example: a + b (a,b both are operands)

Q61. How many types of operators are there in JavaScript?

Answer: There are 3 types of operators in JavaScript:

1. Unary Operators
2. Binary Operators
3. Ternary Operators
Q62. What are arithmetic operators?

Answer: Arithmetic operators perform basic mathematical operations like


addition, subtraction, multiplication, and division.
Q63. What are comparison operators?

Answer: Comparison operators are used to compare two values and give a
Boolean result.

Q64. What is the output for the below code?

var a="10";
var b="hello";
var c=2;
var d=4;
console.log(a+b+c*d);

Answer: 10hello8

Q65. What is the output for the below code?

var a=10;
var b=3;
var c=2;
var d=4;
console.log(a+b+c*d);

Answer: 21

Q66. What is the output for the below code?

var a=10;
var b=3;
var c=2;
var d=4;
console.log(a+b-c*d);

Answer: 5
Q67. What is the output for the below code?

var a=10;
var b=3;
var c=2;
var d=4;
console.log(a*b-c*d);

Answer: 22

Q68. What is the output for the below code?

var a=10;
var b=3;
var c=2;
var d=4;
console.log(a*b-c+d);

Answer: 32

Q69. What is the output for the below code?

var a=10;
var b=3;
var c="2";
var d=4;
console.log(a*b-c+d);
Answer: 32

Q70. What is the output for the below code?

var a=10;
var b=3;
var c= 2;
var d="4";
console.log(a*b-c+d);
Answer: 284

Q71. What is the output for the below code?

var a="10";
var b="3";
var c= 2;
var d=4;
console.log(a+b-c*d);

Answer: 95

Q72. What is the output for the below code?

var a="10";
var b="hello";
var c= 2;
var d=4;
console.log(a+b-c*d);
Answer: NaN
Q73. What is the output for the below code?

var a="10";
var b="hello";
var c= 2;
var d=4;
console.log(a+b-c+d);
Answer: NaN
Q74. What is the output for the below code?

var a="10";
var b="hello";
var c= 2;
var d=4;
console.log(a+b+c+d);

Answer: 10hello24

Q75. What is the output for the below code?

var a="10";
var b=false;
console.log(a+b);

Answer: 10false

Q76. What is the output for the below code?

var a=10;
var b=false;
console.log(a+b);

Answer: 10

Q77. What is the output for the below code?

var a=10;
var b=true;
console.log(a+b);

Answer: 11

Q78. What is the output for the below code?

var a="100";
var b=true;
console.log(a+b);

Answer: 100true

Q79. What is the output for the below code?

var a="100";
var b=true;
var c=14;
console.log(a+b+c);

Answer: 100true14

Q80. What is the output for the below code?

var a="100";
var b=true;
var c=14;
console.log(a+b-c);

Answer: NaN

Q81. What is the output for the below code?

var a=100;
var b=true;
var c=14;
console.log(a+b-c);

Answer: 87

Q82. What is the output for the below code?

var a=5;
var b=4;
var c=true;
console.log(a+b*c);

Answer: 9

Q83. What is the output for the below code?

var a=5;
var b=true;
var c=4;
console.log(a*b-c);

Answer: 1

Q84. What is the output for the below code?

var a=5;
var b=false;
var c=4;
console.log(a*b+c)

Answer: 4

Q85. What is the output for the below code?

var a=5;
var b=null;
console.log(a + b);

Answer: 5

Q86. What is the output for the below code?

var a="5";
var b=null;
console.log(a + b);

Answer: 5null

Q87. What is the output for the below code?

var a=5;
var b=null;
var c=true;
console.log(a + b + c);
Answer: 6

Q88. What is the output for the below code?

var a=5;
var b=null;
var c=true;
var d="14"
console.log(a + b + c + d)

Answer: 614
Q89. What is the output for the below code?

var a=5;
var b=null;
var c=true;
var d="14"
console.log(a + b * c + d)

Answer: 514

Q90. What is the output for the below code?


var a=5;
var b=null;
var c=true;
var d="14"
console.log(a + b * c - d);

Answer: -9

Q91. What is the output for the below code?

var a=5;
var b=undefined;
console.log(a + b)

Answer: NaN

Q92. What is the output for the below code?

var a=45;
var b=undefined;
var c=14;
console.log(a + b + c);

Answer: NaN

Q93. What is the output for the below code?

var a=45;
var b=undefined;
var c=14;
console.log(a * b + c);

Answer: NaN

Q94. What is the output for the below code?

var a=45;
var b=undefined;
var c="";
console.log(a + b + c);

Answer: NaN

Q95. What is the output for the below code?

var a=10;
var b="14";
var c="";
console.log(a + b + c)

Answer: 1014

Q96. What is the output for the below code?

var a=10;
var b="14";
var c=" ";
console.log(a + b * c)

Answer: 10

Q97. What are the falsy values?

1. 0
2. false
3. null
4. NaN
5. ““

Q98. What is the value for the true?

Answer: 1
Q99. What is the value for the false?

Answer: 0
Q100. What is the output for the below code?

var a=10;
var b="14";
var c=" ";
var d= true;
console.log(a + b * c + d);

Answer: 11
Q101. What is the return data type for relational operators?

Answer: Boolean(true or false)

Q102. What is the output for the below code?

var a=10;
var b=14;
console.log(a > b);

Answer: false
Q103. What is the output for the below code?

var a=10;
var b=24;
console.log(a < b);

Answer: true

Q104. What is the output for the below code?

var a=10;
var b=4;
console.log(a <= b)
Answer: false

Q105. What is the output for the below code?

var a=10;
var b=10;
console.log(a <= b)

Answer: true

Q106. What are the relational operators are there in javascript?

Answer: <,>,<=,>=,==,===,!=,!==

Q107. What is the output for the below code?

var a=20;
var b=20;
console.log(a < b);

Answer: false

Q108. What is the output for the below code?

var a=20;
var b="20";
console.log(a == b);

Answer: true

Q109. What is the output for the below code?

var a=20;
var b="20";
console.log(a === b);

Answer: false

Q110. What is the difference between “==” and “===” in javascript?

Answer:
“===” checks the equality along with the data type.
“==” checks the equality only.

Q111. What is the output for the below code?

var a=10;
var b="20";
console.log(a === b);

Answer: false

Q122. What is the output for the below code?

var a=10;
var b="20";
console.log(a !== b);

Answer: true

Q123. What is the output for the below code?

var a= 10;
var b="10";
console.log(a != b);

Answer: false
Q124. What is the output for the below code?

var a= 10;
var b=false;
console.log(a == b);

Answer: false
Q125. What is the output for the below code?

var a= 0;
var b=false;
console.log(a == b);

Answer: true

Q126. What is the output for the below code?

var a= 0;
var b=false;
console.log(a === b);

Answer: false
Q127. What is the output for the below code?

var a= 1;
var b= false;
console.log(a == b);
Answer: false

Q128. What is the output for the below code?

var a= 1;
var b= false;
console.log(a !== b)
Answer: true

Q129. What is the output for the below code?

var a= 10;
var b= false;
console.log(a >= b)

Answer: true

Q130. What is the output for the below code?

var a= 19;
var b= "10";
console.log(a >= b);

Answer: true

Q131. What is the output for the below code?

var a=10;
var b=10;
console.log(a < b);

Answer: false

Q132. What is the output for the below code?

var a= true;
var b= false;
console.log(a > b);

Answer: true
Q133. What is the output for the below code?

var a= true;
var b= false;
console.log(a < b);

Answer: false

Q134. What is the output for the below code?

var a= true;
var b= false;
console.log(a == b);

Answer: false

Q135. What is the output for the below code?

var a= true;
var b= false;
console.log(a === b);

Answer: false

Q136. What is the output for the below code?

var a= false;
var b= " ";
console.log(a == b);

Answer: true
Q137. What is the output for the below code?

var a= false;
var b= " ";
console.log(a <= b);

Answer: true

Q138. What is the output for the below code?

var a= false;
var b= "10";
console.log(a <= b);

Answer: true

Q139. What is the output for the below code?

var a= true;
var b= "10";
console.log(a <= b);

Answer: true

Q140. What is the output for the below code?

var a= true;
var b= "10";
console.log(a === b);

Answer: false
Q141. What is the output for the below code?

var x;
console.log(x);

Answer: undefined

Q142. What is typecasting in javascript?

Answer: Change one data type to another data type is called typecasting
Q143. How many binary operators are there in javascript?

1. Arthemetic Operators
2. Relational Operators
3. Logical Operators
4. Equality Operators
5. Assignment Operators

Q144. What is the unary operator?

Answer: Single operator it will gives a result it is called “unary Operator”

Q145. What are the unary operators are there in javascript?

Answer: +,-,!,++,--

Q146. What is the output for the below code and why?

var a=+10;
var b;
b=a;
console.log(b);
Answer: 10
In javascript always right side values are assigned to leftside variable.
Q147. What is the output for the below code?

var a=true;
var b;
b=!a;
console.log(b);

Answer: false
Q148. What is the output for the below code?

var a=100;
var b;
b=-a;
console.log(b)

Answer: -100
Q149. What is the output for the below code?

var a="123a";
var b=487;
var c=a+b;
console.log(c);
console.log(typeof(c));

Answer: 123a487
string

Q150. What is the output for the below code?

var a="123a";
var b=487;
var c=a-b;
console.log(c);
Answer: NaN
Q151. What is the output for the below code?

var a=null;
var b=true;
var c= a * b;
console.log(c);

Answer: 0

Q152. What is the output for the below code?

var a=null;
var b=true;
console.log(a-b);

Answer: -1

Q153. What is the output for the below code?

var a=10;
a++;
console.log(a);

Answer: 11

Q154. What is the output for the below code?

var a=10;
var b;
b=a++;
console.log(b);

Answer: 10
Q155. What is the output for the below code?

var a=10;
var b;
b=++a;
console.log(b);

Answer: 11

Q156. What is the output for the below code?

var a=10;
var b;
b=a++;
console.log(b);
console.log(a);

Answer: 10
11

Q157. Logical operators works on which data type?

Answer: Logical operators works on boolean values.

Q158. What is the output for the below code?

var a=true;
var b=false;
var c;
c = a && b;
console.log(c);

Answer: false
Q159. What is the output for the below code?

var a=true;
var b=false;
var c;
c = a || b;
console.log(c);

Answer: true
Q160. What is the output for the below code?

var a=true;
var b=100;
var c;
c = a || b;
console.log(c);

Answer: true
Q161. What is the output for the below code?

var a=true;
var b=100;
var c;
c = a || ++b;
console.log(c);
Answer: true
Q162. What is the output for the below code?

var a=true;
var b=100;
var c;
c = a && ++b;
console.log(c);
Answer: 101
Q163. What is the output for the below code?

var a=false;
var b=100;
var c;
c = a && ++b;
console.log(c);
console.log(b);

Answer: false
100
Q164. What is the output for the below code?

var a=14;
var b=10;
var c=30;
console.log(a>b && c<b);

Answer: false
Q165. What is the output for the below code?

var a=14;
var b=10;
var c=30;
console.log(a<b && c<b);

Answer: false
Q166. What is the output for the below code?

var a=14;
var b=10;
var c=30;
console.log(a>b && c>b);
Answer: true
Q167. What is the output for the below code?

var a=14;
var b=10;
var c=30;
console.log(a>b || c>b);

Answer: true

Q168. What is the output for the below code?

var a=14;
var b=10;
var c=30;
console.log(a<b || c>b);

Answer: true
Q169. What is the output for the below code?

var a=false;
var b=123;
var c=100;
var d=null;
console.log(a || b || c || d);

Answer: 123
Q170. What is the output for the below code?

var a=600;
var b=200;
var c=300;
var d=400;
console.log(a<b || a<c || a<d || c<b);
Answer: false
Q171. What is the output for the below code?

var a=0;
var b=false;
var c=9;
var d=14;
console.log(a && b && c && d);

Answer: 0

Q172. What is the output for the below code?

var a=100;
var b="india";
var c='';
var d='sindhu';
console.log(a || b|| c|| d);

Answer: 100

Q173. What is the output for the below code?

var a=100;
var b="india";
var c=null;
var d='sindhu';
console.log(a && b && c && d);

Answer: null

Q174. What does the ternary operator do?

syntax is: (condition) ? statement 1 : statement 2


If the condition is true prints the statement1.
If the condition is false prints the statement2.
Q175. What is the output for the below code?Why?

var x=2<4? 100+200 :"sindhu";


console.log(x);

Answer: 300 (Because condition is true prints the 1st statement)

Q176. What is the output for the below code?

var x=149%2===0?true:false;
console.log(x);

Answer: false

Q177. What is the output for the below code?

var x=234>=100 && 234<=999?true:false;


console.log(x)

Answer: true

Q178. What is the output for the below code?

var x = 194 % 10 === 4 ? true : false;


console.log(x);

Answer: true

Q179. What is the output for the below code?

var x=-14>0?true:false;
console.log(x)

Answer: false
Q180. What is the output for the below code?

var x=-9>0?20+4:10+20;
console.log(x);

Answer: 30

You might also like