Popular JavaScript Interview Questions with Answers.
JavaScript is the most popular language with ample job opportunities. Here is the list of 20 most asked javascript interview questions to speed up your preparation.
1. What's the difference between undefined and null?
"undefined" is the default value of a variable that has not been assigned a specific value and "null" is a value that represents no value.
3. What does the || operator do?
The || or Logical OR operator finds the first truthy expression in its operands and returns it. This too employs short-circuiting to prevent unnecessary work.
4. What is DOM?
DOM stands for Document Object Model is an interface (API) for HTML and XML documents. When the browser first reads our HTML document it creates a big object, a really big object based on the HTML document this is the DOM.
5. What is Event Propagation?
Event propagation is a mechanism that defines how events propagate or travel through the DOM tree to arrive at its target and what happens to it afterward.
6. What's Event Bubbling?
In the Bubbling Phase, the event bubbles up or it goes to its parent, to its grandparents, to its grandparent's parent until it reaches all the way to the window.
7. What's Event Capturing?
In Capturing Phase, the event starts from the window all the way down to the element that triggered the event.
8. What is event.target?
The event.target is the element on which the event occurred or the element that triggered the event.
9. What's the difference between == and === ?
The difference between ==(abstract equality) and ===(strict equality) is that the == compares by value after coercion and === compares by value and type without coercion.
10. Why does it return false when comparing two similar objects in JavaScript?
JavaScript compares objects and primitives differently. In primitives, it compares them by value while in objects it compares them by reference or the address in memory where the variable is stored.
11. What does the !! operator do?
The Double NOT operator or !! coerces the value on the right side into a boolean. Basically, it's a fancy way of converting a value into a boolean.
12. How to evaluate multiple expressions in one line?
We can use the, or comma operator to evaluate multiple expressions in one line. It evaluates from left-to-right.
Example -
x = (x++ , x = addFive(x), x *= 2, x -= 5, x += 10);
13. What is Hoisting?
Hoisting is the term used to describe the moving of variables and functions to the top of their (global or function) scope on where we define that variable or function.
14. What is Scope?
Scope in JavaScript is the area where we have valid access to variables or functions.
JavaScript has three types of Scopes -
1. Global Scope
2. Function Scope
3. Block Scope(ES6).
15. What are the falsy values in JavaScript?
falsy values are values that when converted to boolean becomes false.
16. What does "use strict" do?
"use strict" is an ES5 feature in JavaScript that makes our code in Strict Mode in functions or entire scripts. Strict Mode helps us avoid bugs early on in our code and adds restrictions to it.
17. What's the value of this in JavaScript?
"this" refers to the value of the object that is currently executing or invoking the function.
18. What is the prototype of an object?
A prototype in simplest terms is a blueprint of an object. It is used as a fallback for properties and methods if it does exist in the current object. It's the way to share properties and functionality between objects.
19. What are Higher Order Functions?
Higher-Order Function is functions that can return a function or receive argument or arguments which have a value of a function.
20. What's the difference between var, let, and const keywords?
Variables declared with "var" keyword are function scoped. Variables declared with "let" and "const" keyword are block-scoped.
Difference b/w let & const we can assign new values using let but we can't in const
JavaScript is the most popular language with ample job opportunities. Here is the list of 20 most asked javascript interview questions to speed up your preparation.
1. What's the difference between undefined and null?
"undefined" is the default value of a variable that has not been assigned a specific value and "null" is a value that represents no value.
3. What does the || operator do?
The || or Logical OR operator finds the first truthy expression in its operands and returns it. This too employs short-circuiting to prevent unnecessary work.
4. What is DOM?
DOM stands for Document Object Model is an interface (API) for HTML and XML documents. When the browser first reads our HTML document it creates a big object, a really big object based on the HTML document this is the DOM.
5. What is Event Propagation?
Event propagation is a mechanism that defines how events propagate or travel through the DOM tree to arrive at its target and what happens to it afterward.
6. What's Event Bubbling?
In the Bubbling Phase, the event bubbles up or it goes to its parent, to its grandparents, to its grandparent's parent until it reaches all the way to the window.
7. What's Event Capturing?
In Capturing Phase, the event starts from the window all the way down to the element that triggered the event.
8. What is event.target?
The event.target is the element on which the event occurred or the element that triggered the event.
9. What's the difference between == and === ?
The difference between ==(abstract equality) and ===(strict equality) is that the == compares by value after coercion and === compares by value and type without coercion.
10. Why does it return false when comparing two similar objects in JavaScript?
JavaScript compares objects and primitives differently. In primitives, it compares them by value while in objects it compares them by reference or the address in memory where the variable is stored.
11. What does the !! operator do?
The Double NOT operator or !! coerces the value on the right side into a boolean. Basically, it's a fancy way of converting a value into a boolean.
12. How to evaluate multiple expressions in one line?
We can use the, or comma operator to evaluate multiple expressions in one line. It evaluates from left-to-right.
Example -
x = (x++ , x = addFive(x), x *= 2, x -= 5, x += 10);
13. What is Hoisting?
Hoisting is the term used to describe the moving of variables and functions to the top of their (global or function) scope on where we define that variable or function.
14. What is Scope?
Scope in JavaScript is the area where we have valid access to variables or functions.
JavaScript has three types of Scopes -
1. Global Scope
2. Function Scope
3. Block Scope(ES6).
15. What are the falsy values in JavaScript?
falsy values are values that when converted to boolean becomes false.
16. What does "use strict" do?
"use strict" is an ES5 feature in JavaScript that makes our code in Strict Mode in functions or entire scripts. Strict Mode helps us avoid bugs early on in our code and adds restrictions to it.
17. What's the value of this in JavaScript?
"this" refers to the value of the object that is currently executing or invoking the function.
18. What is the prototype of an object?
A prototype in simplest terms is a blueprint of an object. It is used as a fallback for properties and methods if it does exist in the current object. It's the way to share properties and functionality between objects.
19. What are Higher Order Functions?
Higher-Order Function is functions that can return a function or receive argument or arguments which have a value of a function.
20. What's the difference between var, let, and const keywords?
Variables declared with "var" keyword are function scoped. Variables declared with "let" and "const" keyword are block-scoped.
Difference b/w let & const we can assign new values using let but we can't in const
JavaScript Quiz 🏆
Comment the output of this code?
let nums = [110, 15, 25];
let sum = nums[1]+nums.sort( )[1];
console.log(sum);
Comment the output of this code?
let nums = [110, 15, 25];
let sum = nums[1]+nums.sort( )[1];
console.log(sum);
The route into the web development world seems puzzled at times.
Let's simplify this path for you.
A guide to become a web developer in 180 Days!
Anyone can become a web developer.
it’s a question of consistency & effort. If you put work into it, you can become web developer.
180 days is not guaranteed. It may take longer or it may be quicker all depends on how much you want it & how much effort you’re willing to put in
Days 1–20: Basics of HTML and CSS
Having strong fundamentals gives you the ability to grasp different subjects more quickly.
HTML is the building block of every website and web application.
CSS is used to style websites and web applications.
MDN web docs is best way to startMDN's guide to getting started with the web link here
- Started with the web overview
- What will your website look like?
- Dealing with files
- HTML basics
- CSS basics
- JavaScript basics
- Publishing your website
- How the Webworks
Day 20–60: Learn the Basics of JavaScript
JavaScript powers the web.
Thanks to its popularity, there are a lot of places to learn JavaScript. If you’re just starting out, I’d recommend starting out with the FreeCodeCamp JavaScript curriculum.
It’s free, effective.
Days 61–91: 30 Day Vanilla JS Coding Challenge
“Javascript30” is for beginner to intermediate developers who want to become comfortable with both JavaScript fundamentals and working in the DOM without a library.
Remember 👉 We learn by building apps.
The course is free & fun.
Days 92–130: Learn any one of these (React, Angular, Vue)
I know It’s hard to decide which framework to go for as there are just too many options.
My advice would be to research your location to see which frameworks are most popular and stick to that.
Images here
Days 131-170: Learn Node, MongoDB, and PostgreSQL
Now that you’ve learned how frontend development works, let’s add some backend knowledge to your inventory.
In modern days, a backend is an Application Programming Interface (API) that interacts with the frontend.Here’s a bigger picture of how all the technologies are connected.
You’re not expected to know all of it, but it helps to be familiar with the bigger picture & understanding where you fit in.
n/w graph displays this which tech is most highly correlated with each other.
Images here
171–180: Learn Git
Learn how to use Git to host your projects on Github Pages. it costs you nothing.
Github pages are free, the only downside is you can only host client-side code.
Most teams use Git to share code. Knowing Git makes you more employable.Day 181: Start Applying for Web Development Jobs
You made it to the finish line.
Your actual journey starts now. It's a life long commitment towards more & more learning & building stuff.
Starting out is never easy and giving up seems like the easy way out.
Never give up!
Let's simplify this path for you.
A guide to become a web developer in 180 Days!
Anyone can become a web developer.
it’s a question of consistency & effort. If you put work into it, you can become web developer.
180 days is not guaranteed. It may take longer or it may be quicker all depends on how much you want it & how much effort you’re willing to put in
Days 1–20: Basics of HTML and CSS
Having strong fundamentals gives you the ability to grasp different subjects more quickly.
HTML is the building block of every website and web application.
CSS is used to style websites and web applications.
MDN web docs is best way to startMDN's guide to getting started with the web link here
- Started with the web overview
- What will your website look like?
- Dealing with files
- HTML basics
- CSS basics
- JavaScript basics
- Publishing your website
- How the Webworks
Day 20–60: Learn the Basics of JavaScript
JavaScript powers the web.
Thanks to its popularity, there are a lot of places to learn JavaScript. If you’re just starting out, I’d recommend starting out with the FreeCodeCamp JavaScript curriculum.
It’s free, effective.
Days 61–91: 30 Day Vanilla JS Coding Challenge
“Javascript30” is for beginner to intermediate developers who want to become comfortable with both JavaScript fundamentals and working in the DOM without a library.
Remember 👉 We learn by building apps.
The course is free & fun.
Days 92–130: Learn any one of these (React, Angular, Vue)
I know It’s hard to decide which framework to go for as there are just too many options.
My advice would be to research your location to see which frameworks are most popular and stick to that.
Images here
Days 131-170: Learn Node, MongoDB, and PostgreSQL
Now that you’ve learned how frontend development works, let’s add some backend knowledge to your inventory.
In modern days, a backend is an Application Programming Interface (API) that interacts with the frontend.Here’s a bigger picture of how all the technologies are connected.
You’re not expected to know all of it, but it helps to be familiar with the bigger picture & understanding where you fit in.
n/w graph displays this which tech is most highly correlated with each other.
Images here
171–180: Learn Git
Learn how to use Git to host your projects on Github Pages. it costs you nothing.
Github pages are free, the only downside is you can only host client-side code.
Most teams use Git to share code. Knowing Git makes you more employable.Day 181: Start Applying for Web Development Jobs
You made it to the finish line.
Your actual journey starts now. It's a life long commitment towards more & more learning & building stuff.
Starting out is never easy and giving up seems like the easy way out.
Never give up!
Want to develop your career as a programmer?
How Can You Make Yourself a Reliable/Valuable Programmer?
The Three R's of winning teams are Reliable, Results and Relationships.
But a reliable team is built on reliable team members aka Developer.
Here are few ways to help you become one of them.
1⃣Code the real world, and code frequently
There is no replacement for coding solutions to real-world problems and the practice that comes from these experiences.
"What you code isn't as important as coding as frequently as possible and challenging yourself."
2⃣People inherently value reliability.
In fact, every day we value:
- Reliable mail that gets delivered on time
- Reliable investments that deliver expected returns
- Reliable vendors who show up on time
The most important question to ask is
"How reliable am I?"
3⃣Proactively Communicate.
Avoid surprises. If you make a promise that you can't meet because of truly unforeseen circumstances, let the person know as soon as possible.
Respond to emails within 24 to 48 hours, even just say
"I got it and will get back to you by next week."
4⃣Join a local user group or mentorship program
"The thing that has helped me the most in becoming a better programmer has been working with highly skilled programmers,"
"Try to work always with people more skilled than you, this way you'll learn a lot."
5⃣Develop a specialty
My advice is to specialize by focusing on a smaller segment of tech, such as AWS, front-end web development, etc then keep up with that industry, learn everything, be the best.
That's how you'll win in your career.
6⃣Take code review seriously
Code review is not just an effective way to catch bugs.
it's also a great way to discuss and share knowledge between team members.
"As the reviewee, be receptive towards constructive criticism and take advantage of your reviewers"
7⃣Excel Daily
Implement daily disciplines to sharpen your focus, and strive for everyday excellence.
The reliable person chooses to focus on what he or she can control and to excel regardless of circumstances.
"If you can't get out of it, get into it."
8⃣Respect Time
If you tell someone you can meet at a certain time, Being on time shows others that you are a person of your word. When late, you are saying,
"My time is more valuable than your time."
Take baby steps & actions soon You will become more reliable each day.
How Can You Make Yourself a Reliable/Valuable Programmer?
The Three R's of winning teams are Reliable, Results and Relationships.
But a reliable team is built on reliable team members aka Developer.
Here are few ways to help you become one of them.
1⃣Code the real world, and code frequently
There is no replacement for coding solutions to real-world problems and the practice that comes from these experiences.
"What you code isn't as important as coding as frequently as possible and challenging yourself."
2⃣People inherently value reliability.
In fact, every day we value:
- Reliable mail that gets delivered on time
- Reliable investments that deliver expected returns
- Reliable vendors who show up on time
The most important question to ask is
"How reliable am I?"
3⃣Proactively Communicate.
Avoid surprises. If you make a promise that you can't meet because of truly unforeseen circumstances, let the person know as soon as possible.
Respond to emails within 24 to 48 hours, even just say
"I got it and will get back to you by next week."
4⃣Join a local user group or mentorship program
"The thing that has helped me the most in becoming a better programmer has been working with highly skilled programmers,"
"Try to work always with people more skilled than you, this way you'll learn a lot."
5⃣Develop a specialty
My advice is to specialize by focusing on a smaller segment of tech, such as AWS, front-end web development, etc then keep up with that industry, learn everything, be the best.
That's how you'll win in your career.
6⃣Take code review seriously
Code review is not just an effective way to catch bugs.
it's also a great way to discuss and share knowledge between team members.
"As the reviewee, be receptive towards constructive criticism and take advantage of your reviewers"
7⃣Excel Daily
Implement daily disciplines to sharpen your focus, and strive for everyday excellence.
The reliable person chooses to focus on what he or she can control and to excel regardless of circumstances.
"If you can't get out of it, get into it."
8⃣Respect Time
If you tell someone you can meet at a certain time, Being on time shows others that you are a person of your word. When late, you are saying,
"My time is more valuable than your time."
Take baby steps & actions soon You will become more reliable each day.
How to be a 🔥 developer!
a (DETAILED) Post
a (DETAILED) Post
Telegraph
How to be a 🔥 developer!
ᴰᵒᵖᵖᵉˡᵍᵃⁿᵍᵉʳ 多佩尔甘格尔 1. Practice (important) The more you practice, the more you: ~ learn things ~ remember the learned things ~ find out new ways of doing things ~ implement things faster ~ increase confidence 2. Read code written by others Super helpful…
10: Magic Constants
Telegraph
Magic Constants
Magic constants are the predefined constants in PHP which get changed on the basis of their use. They start with double underscore (__) and ends with double underscore. They are similar to other predefined constants but as they change their values with the…
13: PHP Data Types
Telegraph
PHP Data Types
PHP data types are used to hold different types of data or values. PHP supports 8 primitive data types that can be categorized further in 3 types: Scalar Types Compound Types Special Types PHP Data Types: Scalar Types There are 4 scalar data types in PHP.…