SlideShare a Scribd company logo
21 Essential JavaScript
Interview Questions
by Codementor Nishant Kumar
What is the difference between undefined
and not defined in JavaScript?
Question 1:
What will be the output of the code below?
var y = 1;
if (function f(){}) {
y += typeof f;
}
console.log(y);
Question 2:
What is the drawback of creating
true private methods in JavaScript?
Question 3:
What is a “closure” in JavaScript?
Provide an example.
Question 4:
Write a mul function which will produce the following
outputs when invoked:

javascript console.log(mul(2)(3)(4)); // output : 24
console.log(mul(4)(3)(4)); // output : 48
Question 5:
How do you empty an array in JavaScript?
Question 6:
How do you check if an object is an array or not?
Question 7:
What will be the output of the following code?
var output = (function(x){
delete x;
return x;
})(0);
console.log(output);
Question 8:
What will be the output of the following code?
var x = 1;
var output = (function(){
delete x;
return x;
})();
console.log(output);
Question 9:
What will be the output of the following code?
var x = { foo : 1};
var output = (function(){
delete x.foo;
return x.foo;
})();
console.log(output);
Question 10:
What will be the output of the following code?
var x = { foo : 1};
var Employee = {
company: 'xyz'
}
var emp1 = Object.create(Employee);
delete emp1.company
console.log(emp1.company);
Question 11:
What is undefined x 1 in JavaScript?
Question 12:
What will be the output of the following code?
Question 13:
var trees = ["xyz","xxxx","test","ryan","apple"];
delete trees[3];
console.log(trees.length);
What will be the output of the following code?
var bar = true;
console.log(bar + 0);
console.log(bar + "xyz");
console.log(bar + true);
console.log(bar + false);
Question 14:
What will be the output of the following code?
var x = { foo : 1};
var z = 1, y = z = typeof y;
console.log(y);
Question 15:
What will be the output of the following code?
// NFE (Named Function Expression
var foo = function bar(){ return 12; };
typeof bar();
Question 16:
What is the difference between the following two
functions?
Question 17:
var foo = function(){
// Some code
};
function bar(){
// Some code
};
What is function hoisting in JavaScript?
Question 18:
What will be the output of the following code?
Question 19:
var salary = "1000$";
(function () {
console.log("Original salary was " + salary);
var salary = "5000$";
console.log("My New Salary " + salary);
})();
What is the instanceof operator in JavaScript?
What would be the output of the code below?
Question 20:
function foo(){
return foo;
}
new foo() instanceof foo;
If we have a JavaScript associative array
Question 21:
var counterArray = {
A : 3,
B : 4
};
counterArray["C"] = 1;
How can we calculate length of its counterArray?
Did you know how to answer all 21 questions?
Feel free to check your answers
& view detailed explanations here!

More Related Content

PPTX
Introduction to Node js
PDF
NodeJS for Beginner
PDF
Introduction to Spring Boot!
PDF
Angular
PPTX
Introduction to React JS
PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
PPTX
Introduction to Node js
NodeJS for Beginner
Introduction to Spring Boot!
Angular
Introduction to React JS
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...

What's hot (20)

PPTX
PPTX
React Hooks
PDF
ES6 presentation
PDF
Angular - Chapter 4 - Data and Event Handling
PPTX
Angular interview questions
PPTX
Angular modules in depth
PPT
HTML Introduction
PPTX
What is component in reactjs
PPTX
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
PPT
jQuery Ajax
PPTX
HTML/HTML5
PPTX
Build RESTful API Using Express JS
PPTX
Express js
PPT
Node.js Basics
PPTX
Basic Concept of Node.js & NPM
PPT
A Deeper look into Javascript Basics
PPTX
Understanding react hooks
PPT
Learning Html
React Hooks
ES6 presentation
Angular - Chapter 4 - Data and Event Handling
Angular interview questions
Angular modules in depth
HTML Introduction
What is component in reactjs
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
jQuery Ajax
HTML/HTML5
Build RESTful API Using Express JS
Express js
Node.js Basics
Basic Concept of Node.js & NPM
A Deeper look into Javascript Basics
Understanding react hooks
Learning Html
Ad

Similar to 21 Essential JavaScript Interview Questions (20)

PDF
ES2015 Quiz
PPTX
Java SE 17 Study Guide for Certification - Chapter 01
DOCX
CMIS 141 7984 Introductory Programming (2158)A non-local boole.docx
PDF
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
PPTX
Computer ScienceTechnical quiz
PDF
All based on Zybooks = AP Java with zylabsQUESTION 1char[][] tab.pdf
PDF
A la découverte de TypeScript
PDF
Fnt software solutions placement paper
PDF
Improving Java performance at JBCNConf 2015
PDF
Advanced Debugging Using Java Bytecodes
DOCX
Mcq cpup
PDF
Review Questions for Exam 10182016 1. public class .pdf
PDF
Java puzzles
PPTX
Novidades do c# 7 e 8
PPTX
Mcq Of Java Script ppt for Teaching and self preparation
PDF
Chapter 9 Flow Of Control Knowledge Boat.pdf
PPT
Introduction to Java Programming Part 2
PPT
Java language fundamentals
PPTX
PyconKR 2018 Deep dive into Coroutine
PPTX
Once Upon a Process
ES2015 Quiz
Java SE 17 Study Guide for Certification - Chapter 01
CMIS 141 7984 Introductory Programming (2158)A non-local boole.docx
[C++ Korea] Effective Modern C++ Study, Item 11 - 13
Computer ScienceTechnical quiz
All based on Zybooks = AP Java with zylabsQUESTION 1char[][] tab.pdf
A la découverte de TypeScript
Fnt software solutions placement paper
Improving Java performance at JBCNConf 2015
Advanced Debugging Using Java Bytecodes
Mcq cpup
Review Questions for Exam 10182016 1. public class .pdf
Java puzzles
Novidades do c# 7 e 8
Mcq Of Java Script ppt for Teaching and self preparation
Chapter 9 Flow Of Control Knowledge Boat.pdf
Introduction to Java Programming Part 2
Java language fundamentals
PyconKR 2018 Deep dive into Coroutine
Once Upon a Process
Ad

More from Arc & Codementor (14)

PDF
Remote Career Summit 2020 - the State of Remote Jobs - Weiting Liu of Arc
PDF
Introduction to Python for Data Science
PPTX
25 php interview questions – codementor
PPTX
20 iOS developer interview questions
PDF
29 Essential AngularJS Interview Questions
PDF
37 Java Interview Questions
PDF
Top 10 Programming Languages in 2015
PDF
How to Build Your App from Scratch
PDF
Angular meteor for angular devs
PDF
Tmux tips and_tricks
PDF
Introduction to Tmux - Codementor Tmux Office Hours Part 1
PPTX
Codementor Office Hours with Eric Chiang: Stdin, Stdout: pup, Go, and life at...
PDF
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
PPTX
Python Internals Optimization Choices Made - Codementors Office Hours with St...
Remote Career Summit 2020 - the State of Remote Jobs - Weiting Liu of Arc
Introduction to Python for Data Science
25 php interview questions – codementor
20 iOS developer interview questions
29 Essential AngularJS Interview Questions
37 Java Interview Questions
Top 10 Programming Languages in 2015
How to Build Your App from Scratch
Angular meteor for angular devs
Tmux tips and_tricks
Introduction to Tmux - Codementor Tmux Office Hours Part 1
Codementor Office Hours with Eric Chiang: Stdin, Stdout: pup, Go, and life at...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Python Internals Optimization Choices Made - Codementors Office Hours with St...

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
top salesforce developer skills in 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
System and Network Administration Chapter 2
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
L1 - Introduction to python Backend.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
ai tools demonstartion for schools and inter college
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
history of c programming in notes for students .pptx
PPTX
Transform Your Business with a Software ERP System
Adobe Illustrator 28.6 Crack My Vision of Vector Design
top salesforce developer skills in 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PTS Company Brochure 2025 (1).pdf.......
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
VVF-Customer-Presentation2025-Ver1.9.pptx
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
System and Network Administration Chapter 2
Internet Downloader Manager (IDM) Crack 6.42 Build 41
L1 - Introduction to python Backend.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
ai tools demonstartion for schools and inter college
Operating system designcfffgfgggggggvggggggggg
Reimagine Home Health with the Power of Agentic AI​
Computer Software and OS of computer science of grade 11.pptx
history of c programming in notes for students .pptx
Transform Your Business with a Software ERP System

21 Essential JavaScript Interview Questions

  • 1. 21 Essential JavaScript Interview Questions by Codementor Nishant Kumar
  • 2. What is the difference between undefined and not defined in JavaScript? Question 1:
  • 3. What will be the output of the code below? var y = 1; if (function f(){}) { y += typeof f; } console.log(y); Question 2:
  • 4. What is the drawback of creating true private methods in JavaScript? Question 3:
  • 5. What is a “closure” in JavaScript? Provide an example. Question 4:
  • 6. Write a mul function which will produce the following outputs when invoked:
 javascript console.log(mul(2)(3)(4)); // output : 24 console.log(mul(4)(3)(4)); // output : 48 Question 5:
  • 7. How do you empty an array in JavaScript? Question 6:
  • 8. How do you check if an object is an array or not? Question 7:
  • 9. What will be the output of the following code? var output = (function(x){ delete x; return x; })(0); console.log(output); Question 8:
  • 10. What will be the output of the following code? var x = 1; var output = (function(){ delete x; return x; })(); console.log(output); Question 9:
  • 11. What will be the output of the following code? var x = { foo : 1}; var output = (function(){ delete x.foo; return x.foo; })(); console.log(output); Question 10:
  • 12. What will be the output of the following code? var x = { foo : 1}; var Employee = { company: 'xyz' } var emp1 = Object.create(Employee); delete emp1.company console.log(emp1.company); Question 11:
  • 13. What is undefined x 1 in JavaScript? Question 12:
  • 14. What will be the output of the following code? Question 13: var trees = ["xyz","xxxx","test","ryan","apple"]; delete trees[3]; console.log(trees.length);
  • 15. What will be the output of the following code? var bar = true; console.log(bar + 0); console.log(bar + "xyz"); console.log(bar + true); console.log(bar + false); Question 14:
  • 16. What will be the output of the following code? var x = { foo : 1}; var z = 1, y = z = typeof y; console.log(y); Question 15:
  • 17. What will be the output of the following code? // NFE (Named Function Expression var foo = function bar(){ return 12; }; typeof bar(); Question 16:
  • 18. What is the difference between the following two functions? Question 17: var foo = function(){ // Some code }; function bar(){ // Some code };
  • 19. What is function hoisting in JavaScript? Question 18:
  • 20. What will be the output of the following code? Question 19: var salary = "1000$"; (function () { console.log("Original salary was " + salary); var salary = "5000$"; console.log("My New Salary " + salary); })();
  • 21. What is the instanceof operator in JavaScript? What would be the output of the code below? Question 20: function foo(){ return foo; } new foo() instanceof foo;
  • 22. If we have a JavaScript associative array Question 21: var counterArray = { A : 3, B : 4 }; counterArray["C"] = 1; How can we calculate length of its counterArray?
  • 23. Did you know how to answer all 21 questions? Feel free to check your answers & view detailed explanations here!