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

What's hot (20)

PPTX
Relational operators
Graphic Era Hill University,Bhimtal
 
PDF
Lembar penilaian rekayasa perangkat lunak baru
Puguh Rismadi
 
PDF
Object Pool Design Pattern.pdf
Talha Ashraf
 
DOCX
Tugas perancangan basis data pertemuan 1 semester 2 BSI
Sherly Sundiawati
 
PPTX
Les algorithmes d’approximation
Wael Ismail
 
PDF
Cours informatique chapitre 1 ordinateur et système d'exploitation 7ème
Tunisie collège
 
PDF
Informatika dan Keterampilan Generik (IoT)
Farichah Riha
 
PPTX
Python Programming | JNTUA | UNIT 2 | Case Study |
FabMinds
 
PDF
Desain laporan pada java dengan ireport & jcreator
Agung Sulistyanto
 
PPTX
Programming in C Basics
Bharat Kalia
 
PDF
障害管理からチケット駆動開発へ~BTSから始まる進化の歴史
akipii Oga
 
PPTX
functions of C++
tarandeep_kaur
 
PPT
Introduction to C++
Bharat Kalia
 
PDF
lkpd informatika.pdf
NurulIlyas1
 
PDF
Object Oriented Programming Using C++ Practical File
Harjinder Singh
 
PPTX
Sdm di era modern
sulaiman patabang
 
PPTX
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
PPTX
La souris, le clavier
MEMOIRE PATRIMOINE CLOHARS CARNOET
 
PDF
Exercices pascal tous les chapitres
borhen boukthir
 
PDF
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
Lembar penilaian rekayasa perangkat lunak baru
Puguh Rismadi
 
Object Pool Design Pattern.pdf
Talha Ashraf
 
Tugas perancangan basis data pertemuan 1 semester 2 BSI
Sherly Sundiawati
 
Les algorithmes d’approximation
Wael Ismail
 
Cours informatique chapitre 1 ordinateur et système d'exploitation 7ème
Tunisie collège
 
Informatika dan Keterampilan Generik (IoT)
Farichah Riha
 
Python Programming | JNTUA | UNIT 2 | Case Study |
FabMinds
 
Desain laporan pada java dengan ireport & jcreator
Agung Sulistyanto
 
Programming in C Basics
Bharat Kalia
 
障害管理からチケット駆動開発へ~BTSから始まる進化の歴史
akipii Oga
 
functions of C++
tarandeep_kaur
 
Introduction to C++
Bharat Kalia
 
lkpd informatika.pdf
NurulIlyas1
 
Object Oriented Programming Using C++ Practical File
Harjinder Singh
 
Sdm di era modern
sulaiman patabang
 
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
La souris, le clavier
MEMOIRE PATRIMOINE CLOHARS CARNOET
 
Exercices pascal tous les chapitres
borhen boukthir
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 

Similar to 21 Essential JavaScript Interview Questions (20)

PDF
JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
JavaScript(Es5) Interview Questions & Answers
Ratnala Charan kumar
 
PDF
JavaScript Array Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
656981533-100-JavaScript-Interview-QnA.pdf
razaunar000
 
PPTX
JavaScript Interview Questions And Answers | JavaScript Interview Preparation...
Simplilearn
 
PDF
JavaScript Interview Questions 2023
Laurence Svekis ✔
 
PDF
The JavaScript You Wished You Knew
Troy Miles
 
PDF
ES2015 Quiz
Sergey Bolshchikov
 
PPTX
Introduction to JavaScript
Rangana Sampath
 
PDF
JavaScript Interview Questions with Answers
AK Deep Knowledge
 
PPT
An introduction to javascript
MD Sayem Ahmed
 
PDF
OOPS JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
PPT
JavaScript - Programming Languages course
yoavrubin
 
PPTX
Javascript
Prashant Kumar
 
PDF
JavaScript Interview Questions Part - 1.pdf
katarichallenge
 
PPT
data-types-operators-datatypes-operators.ppt
Gagan Rana
 
PDF
JavaScript For CSharp Developer
Sarvesh Kushwaha
 
PPTX
Awesomeness of JavaScript…almost
Quinton Sheppard
 
PDF
JavaScript Programming
Sehwan Noh
 
PPTX
javascript
Kaya Ota
 
JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
JavaScript(Es5) Interview Questions & Answers
Ratnala Charan kumar
 
JavaScript Array Interview Questions PDF By ScholarHat
Scholarhat
 
656981533-100-JavaScript-Interview-QnA.pdf
razaunar000
 
JavaScript Interview Questions And Answers | JavaScript Interview Preparation...
Simplilearn
 
JavaScript Interview Questions 2023
Laurence Svekis ✔
 
The JavaScript You Wished You Knew
Troy Miles
 
ES2015 Quiz
Sergey Bolshchikov
 
Introduction to JavaScript
Rangana Sampath
 
JavaScript Interview Questions with Answers
AK Deep Knowledge
 
An introduction to javascript
MD Sayem Ahmed
 
OOPS JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
JavaScript - Programming Languages course
yoavrubin
 
Javascript
Prashant Kumar
 
JavaScript Interview Questions Part - 1.pdf
katarichallenge
 
data-types-operators-datatypes-operators.ppt
Gagan Rana
 
JavaScript For CSharp Developer
Sarvesh Kushwaha
 
Awesomeness of JavaScript…almost
Quinton Sheppard
 
JavaScript Programming
Sehwan Noh
 
javascript
Kaya Ota
 
Ad

More from Arc & Codementor (14)

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

Recently uploaded (20)

PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Executive Business Intelligence Dashboards
vandeslie24
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 

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!