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
Computer Training in Narnaul
Computer Training in Satnali
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 51:
Which of the following methods can be used to remove an element from an array?
A) pop()
B) splice()
C) shift()
D) All of the above
Answer:
D) All of the above
Question 52:
What is the output of console.log('2' + 2);?
A) 4
B) 22
C) error
D) undefined
Answer:
B) 22
Question 53:
What does the filter() method do in JavaScript?
A) Returns a new array with elements that pass a test
B) Returns a single value based on a test
C) Modifies the original array
D) None of the above
Answer:
A) Returns a new array with elements that pass a test
Question 54:
Which method is used to convert a string to lowercase in JavaScript?
A) toLowerCase()
B) lowercase()
C) toLower()
D) str.lower()
Answer:
A) toLowerCase()
Question 55:
What will console.log([1, 2, 3].map(x => x * 2)); output?
A) [2, 4, 6]
B) [1, 2, 3]
C) undefined
D) error
Answer:
A) [2, 4, 6]
Question 56:
Which of the following is true about let and var?
A) let is block-scoped, while var is function-scoped
B) Both are function-scoped
C) var is block-scoped, while let is function-scoped
D) Both are block-scoped
Answer:
A) let is block-scoped, while var is function-scoped
Question 57:
What is the output of console.log(5 == '5');?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 58:
Which of the following is used to stop the execution of a function?
A) return
B) stop
C) break
D) exit
Answer:
A) return
Question 59:
What will console.log([] == ![]); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 60:
Which of the following is a correct way to use an if statement?
A) if x > 10 { }
B) if (x > 10) { }
C) if [x > 10] { }
D) if {x > 10} { }
Answer:
B) if (x > 10) { }
Question 61:
What is the output of console.log(typeof [] === 'object');?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 62:
Which method would you use to find the last index of an element in an array?
A) lastIndexOf()
B) indexOf()
C) findIndex()
D) search()
Answer:
A) lastIndexOf()
Question 63:
Which of the following will not create a variable in JavaScript?
A) let x;
B) const y;
C) var z = 10;
D) x = 5;
Answer:
B) const y;
Question 64:
What is the output of console.log(2 + 3 * 4);?
A) 20
B) 14
C) 12
D) 8
Answer:
B) 14
Question 65:
How do you define a method in an object?
A) var obj = { myMethod() { } };
B) var obj = { myMethod: function() { } };
C) var obj = { myMethod: () => { } };
D) All of the above
Answer:
D) All of the above
Question 66:
What will console.log(1 + '1' + 1); output?
A) 3
B) 11
C) 21
D) error
Answer:
C) 21
Question 67:
Which of the following is used to trigger an asynchronous operation in JavaScript?
A) async
B) await
C) Promise
D) All of the above
Answer:
D) All of the above
Question 68:
What will be the output of console.log(1 + true);?
A) 2
B) 1
C) undefined
D) error
Answer:
A) 2
Question 69:
Which method can be used to join two or more arrays?
A) combine()
B) join()
C) concat()
D) merge()
Answer:
C) concat()
Question 70:
What is the output of console.log('5' - 2);?
A) 3
B) undefined
C) error
D) NaN
Answer:
A) 3
Question 71:
What will console.log(typeof (function(){})); output?
A) function
B) object
C) undefined
D) error
Answer:
A) function
Question 72:
Which of the following is a correct way to define an arrow function?
A) const add = (a, b) => a + b;
B) const add = (a, b) { return a + b; };
C) const add = (a, b): return a + b;
D) function add(a, b) => a + b;
Answer:
A) const add = (a, b) => a + b;
Question 73:
What will console.log(0 == false); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 74:
What does the reduce() method do in JavaScript?
A) Reduces an array to a single value
B) Filters elements in an array
C) Sorts an array
D) None of the above
Answer:
A) Reduces an array to a single value
Question 75:
Which of the following will create a new object with the same prototype as the original object?
A) Object.create(originalObject);
B) new Object(originalObject);
C) Object.assign({}, originalObject);
D) Both A and C
Answer:
D) Both A and C
Question 76:
What will be the output of console.log(typeof {});?
A) object
B) undefined
C) null
D) error
Answer:
A) object
Question 77:
Which of the following statements is correct?
A) NaN === NaN is true
B) NaN is equal to itself
C) NaN is a number
D) All of the above
Answer:
C) NaN is a number
Question 78:
What will console.log(1 + '1' - 1); output?
A) 11
B) 10
C) 1
D) error
Answer:
B) 10
Question 79:
Which of the following is a method of the Array prototype?
A) push()
B) pop()
C) slice()
D) All of the above
Answer:
D) All of the above
Question 80:
How do you create a new Promise?
A) new Promise() { };
B) new Promise(function(resolve, reject) { });
C) Promise.new() { };
D) All of the above
Answer:
B) new Promise(function(resolve, reject) { });
Question 81:
What will console.log(null == undefined); output?
A) true
B) false
C) undefined
D) error
Answer:
A) true
Question 82:
Which method is used to convert a JSON string into a JavaScript object?
A) JSON.parse()
B) JSON.stringify()
C) JSON.convert()
D) None of the above
Answer:
A) JSON.parse()
Question 83:
Which of the following is true about the `let` keyword in JavaScript?
A) It declares a variable that can be reassigned.
B) It declares a variable that is hoisted.
C) It declares a constant variable.
D) None of the above
Answer:
A) It declares a variable that can be reassigned.
Question 84:
What will console.log(2 + '2'); output?
A) 4
B) 22
C) "2 + 2"
D) error
Answer:
B) 22
Question 85:
Which of the following is a falsy value in JavaScript?
A) 0
B) "" (empty string)
C) null
D) All of the above
Answer:
D) All of the above
Question 86:
What is the output of console.log(typeof NaN);?
A) number
B) string
C) object
D) error
Answer:
A) number
Question 87:
Which of the following methods can be used to remove the last element from an array?
A) pop()
B) shift()
C) delete()
D) slice()
Answer:
A) pop()
Question 88:
How do you declare a constant variable in JavaScript?
A) const myVar;
B) constant myVar;
C) let myVar = constant;
D) var myVar = constant;
Answer:
A) const myVar;
Question 89:
Which of the following will create an object?
A) var obj = {};
B) var obj = new Object();
C) Both A and B
D) None of the above
Answer:
C) Both A and B
Question 90:
What does the `this` keyword refer to in JavaScript?
A) The global object
B) The current function
C) The calling object
D) All of the above
Answer:
D) All of the above
Question 91:
How do you add a new element to the end of an array?
A) array.push(element);
B) array.add(element);
C) array.insert(element);
D) None of the above
Answer:
A) array.push(element);
Question 92:
Which of the following is not a JavaScript data type?
A) string
B) boolean
C) undefined
D) float
Answer:
D) float
Question 93:
What will the following code output? console.log(typeof "Hello");
A) string
B) String
C) text
D) error
Answer:
A) string
Question 94:
How do you find the length of an array?
A) array.size;
B) array.length;
C) array.count;
D) None of the above
Answer:
B) array.length;
Question 95:
What is the correct way to write a JavaScript array?
A) var colors = "red", "green", "blue";
B) var colors = ["red", "green", "blue"];
C) var colors = (1:"red", 2:"green", 3:"blue");
D) var colors = {red, green, blue};
Answer:
B) var colors = ["red", "green", "blue"];
Question 96:
Which of the following is a way to define a function in JavaScript?
A) function myFunction() { };
B) var myFunction = function() { };
C) Both A and B
D) None of the above
Answer:
C) Both A and B
Question 97:
What is a closure in JavaScript?
A) A function that remembers its outer variables
B) A block of code that can be reused
C) A data type
D) None of the above
Answer:
A) A function that remembers its outer variables
Question 98:
What does `===` do in JavaScript?
A) Compares value and type
B) Compares value only
C) Checks for reference equality
D) All of the above
Answer:
A) Compares value and type
Question 99:
Which of the following is used to define a JavaScript object?
A) { }
B) [ ]
C) ( )
D) < >
Answer:
A) { }
Question 100:
How can you convert a string to a number in JavaScript?
A) Number(string);
B) parseInt(string);
C) Both A and B
D) None of the above
Answer:
C) Both A and B
«
1
2
3
4
5
6
7
8
9
10
»
Showing 51-100 of 500 questions