HR/Admin : +91-7827547816
Sales : +91-7827547816
+91-9599109956
training@techspakes.com
Toggle navigation
Home
Training Courses
HTML
Website Development
WordPress Development
Front End Development
Graphics Designer
Linux Admin
MERN
Angular
Hybrid Mobile App
Drupal
Full Stack
React Native Developer
MVC
MEAN
SMM
SEO
SMO
Lead Generation
Web Development Training in Noida
Web Development Training in Jaipur
Web Development Training in Chandigarh
Web Development Training in Gurgaon
Our Locations
Computer Training in Dahina
Computer Training in Mahendergarh
Computer Training in Narnaul
Computer Training in Satnali
Computer Training in Rewari
Computer Training in Kanina
Computer Training in Ateli Mandi
Computer Training in Bhiwani
Computer Training in Charkhi Dadri
Interview Questions
HTML Interview Questions
CSS Interview Questions
Bootstrap4 Interview Questions
Bootstrap5 Interview Questions
Javascript Interview Questions
IT Services
Testimonial
Our Top Placements
Contact
Top 500 Javascript MCQ Interview Questions
Training
Top 500 Javascript MCQ Interview Questions
Question 151:
Which of the following can throw an error in JavaScript?
A) throw
B) try
C) catch
D) All of the above
Answer:
D) All of the above
Question 152:
What is the output of console.log(5 % 2);?
A) 2
B) 1
C) 0
D) undefined
Answer:
B) 1
Question 153:
Which of the following is not a method of the Array prototype?
A) push()
B) slice()
C) map()
D) each()
Answer:
D) each()
Question 154:
What will console.log('Hello'.split('l')); output?
A) ['Hel', 'lo']
B) ['Hello']
C) ['H', 'e', '', 'o']
D) error
Answer:
A) ['Hel', 'lo']
Question 155:
What does the reduce() method do?
A) Reduces an array to a single value
B) Filters an array based on a condition
C) Maps an array to a new array
D) None of the above
Answer:
A) Reduces an array to a single value
Question 156:
Which of the following will create a new array from an existing one?
A) Array.from()
B) slice()
C) map()
D) All of the above
Answer:
D) All of the above
Question 157:
What will console.log((2 + 3) * 4); output?
A) 20
B) 12
C) 14
D) error
Answer:
A) 20
Question 158:
Which of the following is a valid way to create a set in JavaScript?
A) let mySet = new Set();
B) let mySet = new Set([]);
C) Both A and B
D) None of the above
Answer:
C) Both A and B
Question 159:
What is the output of console.log('2' == 2);?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 160:
Which of the following is used to declare a constant in JavaScript?
A) var
B) let
C) const
D) constant
Answer:
C) const
Question 161:
What will console.log(2 && 3); output?
A) 2
B) 3
C) undefined
D) error
Answer:
B) 3
Question 162:
What is the output of console.log(1 + '2' + 3);?
A) 123
B) 6
C) 15
D) error
Answer:
A) 123
Question 163:
Which of the following methods can be used to get the keys of an object?
A) Object.keys()
B) Object.values()
C) Object.entries()
D) All of the above
Answer:
A) Object.keys()
Question 164:
What does the find() method do?
A) Returns the first element that satisfies the provided testing function
B) Filters elements based on a condition
C) Maps an array to a new array
D) None of the above
Answer:
A) Returns the first element that satisfies the provided testing function
Question 165:
What will console.log([] + []); output?
A) undefined
B) null
C) ""
D) error
Answer:
C) ""
Question 166:
Which of the following is a falsy value?
A) 1
B) -1
C) 0
D) true
Answer:
C) 0
Question 167:
What is the output of console.log(1 + true);?
A) 2
B) 1
C) error
D) undefined
Answer:
A) 2
Question 168:
What does the some() method do?
A) Checks if at least one element in the array satisfies the condition
B) Filters elements based on a condition
C) Maps an array to a new array
D) None of the above
Answer:
A) Checks if at least one element in the array satisfies the condition
Question 169:
Which of the following will correctly clone an object?
A) let clone = Object.assign({}, obj);
B) let clone = {...obj};
C) let clone = JSON.parse(JSON.stringify(obj));
D) All of the above
Answer:
D) All of the above
Question 170:
What is the output of console.log(3 * null);?
A) 0
B) 3
C) undefined
D) error
Answer:
A) 0
Question 171:
What will console.log(false == 0); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 172:
Which of the following is a higher-order function?
A) map()
B) filter()
C) reduce()
D) All of the above
Answer:
D) All of the above
Question 173:
What is the output of console.log(NaN === NaN);?
A) true
B) false
C) undefined
D) error
Answer:
B) false
Question 174:
What will console.log((2 + 3) == 5); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 175:
Which of the following can be used to handle exceptions in JavaScript?
A) try...catch
B) throw
C) finally
D) All of the above
Answer:
D) All of the above
Question 176:
What will console.log(0 == '0'); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 177:
Which of the following is used to define an asynchronous function in JavaScript?
A) async
B) await
C) Promise
D) All of the above
Answer:
A) async
Question 178:
What will console.log(1 + '1' + 1); output?
A) 11
B) 111
C) 2
D) error
Answer:
B) 111
Question 179:
Which of the following methods is used to parse a JSON string into a JavaScript object?
A) JSON.stringify()
B) JSON.parse()
C) JSON.object()
D) None of the above
Answer:
B) JSON.parse()
Question 180:
What will console.log(typeof NaN); output?
A) "number"
B) "NaN"
C) "undefined"
D) "error"
Answer:
A) "number"
Question 181:
What will console.log(!!"hello"); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 182:
Which of the following is a way to declare a variable in JavaScript?
A) var
B) let
C) const
D) All of the above
Answer:
D) All of the above
Question 183:
What does the Array.isArray() method do?
A) Checks if a value is an array
B) Converts an array to a string
C) Creates a new array
D) None of the above
Answer:
A) Checks if a value is an array
Question 184:
What is the output of console.log(typeof null);?
A) "object"
B) "null"
C) "undefined"
D) "error"
Answer:
A) "object"
Question 185:
How do you create a new array from an existing array by applying a function to each element?
A) array.map()
B) array.forEach()
C) array.reduce()
D) None of the above
Answer:
A) array.map()
Question 186:
Which of the following is NOT a falsy value in JavaScript?
A) 0
B) "" (empty string)
C) null
D) "hello"
Answer:
D) "hello"
Question 187:
What is the purpose of the break statement in JavaScript?
A) Exit a loop
B) Continue to the next iteration of a loop
C) Terminate a function
D) None of the above
Answer:
A) Exit a loop
Question 188:
What is the output of console.log(1 + 2 + "3");?
A) 6
B) "33"
C) "123"
D) error
Answer:
C) "33"
Question 189:
How can you create a new object in JavaScript?
A) Using object literals
B) Using the new keyword
C) Using Object.create()
D) All of the above
Answer:
D) All of the above
Question 190:
What is a closure in JavaScript?
A) A function that retains access to its lexical scope
B) A variable that retains its value
C) A way to create objects
D) None of the above
Answer:
A) A function that retains access to its lexical scope
Question 191:
What does the this keyword refer to in JavaScript?
A) The global object
B) The function where it is defined
C) The object that is executing the current function
D) None of the above
Answer:
C) The object that is executing the current function
Question 192:
Which method is used to remove the last element from an array?
A) pop()
B) shift()
C) splice()
D) unshift()
Answer:
A) pop()
Question 193:
What will console.log(0.1 + 0.2 === 0.3); output?
A) true
B) false
C) undefined
D) error
Answer:
B) false
Question 194:
How do you define a function in JavaScript?
A) function myFunction() {}
B) myFunction() {}
C) define myFunction() {}
D) None of the above
Answer:
A) function myFunction() {}
Question 195:
What is the output of console.log("5" + 5);?
A) 10
B) "55"
C) "5"
D) error
Answer:
B) "55"
Question 196:
What does the Array.push() method do?
A) Adds one or more elements to the end of an array
B) Removes the last element from an array
C) Sorts the array
D) None of the above
Answer:
A) Adds one or more elements to the end of an array
Question 197:
Which of the following is an example of a JavaScript primitive type?
A) Object
B) Array
C) String
D) Function
Answer:
C) String
Question 198:
How do you check if a variable is an array?
A) isArray(variable)
B) variable.isArray()
C) Array.isArray(variable)
D) None of the above
Answer:
C) Array.isArray(variable)
Question 199:
What is the use of the JSON.stringify() method?
A) Convert a JavaScript object into a JSON string
B) Parse a JSON string into a JavaScript object
C) Validate a JSON string
D) None of the above
Answer:
A) Convert a JavaScript object into a JSON string
Question 200:
How do you create a promise in JavaScript?
A) new Promise(function(resolve, reject) {})
B) Promise(function(resolve, reject) {})
C) new Promise(resolve, reject) {}
D) None of the above
Answer:
A) new Promise(function(resolve, reject) {})
«
1
2
3
4
5
6
7
8
9
10
»
Showing 151-200 of 500 questions