๐ JavaScript Interview Questions with Answers โ Part 1
1. What is JavaScript?
JavaScript is a high-level, interpreted programming language used to create interactive and dynamic web pages. It runs in web browsers and can also be used for backend development with Node.js.
Common Uses:
Interactive websites
Form validation
Animations
API calls
Web applications
Backend development
Example:
2. What are the different data types in JavaScript?
JavaScript has two categories of data types.
Primitive Data Types
String
Number
Boolean
Undefined
Null
BigInt
Symbol
Non-Primitive (Reference) Data Types
Object
Array
Function
Example:
3. What is the difference between var, let, and const?
Feature | var | let | const
Scope | Function | Block | Block
Reassign | โ Yes | โ Yes | โ No
Redeclare | โ Yes | โ No | โ No
Hoisted | โ Yes | โ Yes (TDZ) | โ Yes (TDZ)
Example:
Interview Tip:
Use const by default, let when the value changes, and avoid var in modern JavaScript.
4. What are primitive and non-primitive data types?
Primitive Data Types
Stored by value.
Examples:
String
Number
Boolean
Null
Undefined
BigInt
Symbol
Non-Primitive Data Types
Stored by reference.
Examples:
Objects
Arrays
Functions
Example:
Reference Example:
5. What is type coercion?
Type coercion is JavaScript's automatic conversion of one data type into another during operations or comparisons.
Example:
Types:
Implicit coercion (automatic)
Explicit coercion (manual)
Explicit Example:
6. What is the difference between == and ===?
== (Loose Equality)
Compares values only
Performs type conversion
=== (Strict Equality)
Compares both value and data type
No type conversion
Example:
Best Practice:
Always prefer === to avoid unexpected results.
7. What are truthy and falsy values?
Truthy Values
Values treated as true in a boolean context.
Examples:
Non-empty strings
Non-zero numbers
Objects
Arrays
Falsy Values
JavaScript has these falsy values:
false
0
-0
0n
"" (empty string)
null
undefined
NaN
Example:
8. What is undefined?
undefined means a variable has been declared but has not been assigned a value.
Example:
Output:
Key Point:
undefined is assigned automatically by JavaScript.
9. What is null?
null represents an intentional absence of any object value.
It is assigned manually by the developer.
Example:
Output:
Difference:
undefined โ No value assigned.
null โ Empty value assigned intentionally.
10. What is NaN?
NaN stands for Not a Number.
It represents an invalid numeric result.
โค๏ธ Double Tap For Part 2
1. What is JavaScript?
JavaScript is a high-level, interpreted programming language used to create interactive and dynamic web pages. It runs in web browsers and can also be used for backend development with Node.js.
Common Uses:
Interactive websites
Form validation
Animations
API calls
Web applications
Backend development
Example:
console.log("Hello JavaScript");2. What are the different data types in JavaScript?
JavaScript has two categories of data types.
Primitive Data Types
String
Number
Boolean
Undefined
Null
BigInt
Symbol
Non-Primitive (Reference) Data Types
Object
Array
Function
Example:
let name = "Deepak"; // String
let age = 25; // Number
let isActive = true; // Boolean
let data = null; // Null
let value; // Undefined
3. What is the difference between var, let, and const?
Feature | var | let | const
Scope | Function | Block | Block
Reassign | โ Yes | โ Yes | โ No
Redeclare | โ Yes | โ No | โ No
Hoisted | โ Yes | โ Yes (TDZ) | โ Yes (TDZ)
Example:
var a = 10;
let b = 20;
const c = 30;
Interview Tip:
Use const by default, let when the value changes, and avoid var in modern JavaScript.
4. What are primitive and non-primitive data types?
Primitive Data Types
Stored by value.
Examples:
String
Number
Boolean
Null
Undefined
BigInt
Symbol
Non-Primitive Data Types
Stored by reference.
Examples:
Objects
Arrays
Functions
Example:
let a = 10;
let b = a;
b = 20;
console.log(a); // 10
Reference Example:
const obj1 = { name: "John" };
const obj2 = obj1;
obj2.name = "Mike";
console.log(obj1.name); // Mike5. What is type coercion?
Type coercion is JavaScript's automatic conversion of one data type into another during operations or comparisons.
Example:
console.log("5" + 2); // "52"
console.log("5" - 2); // 3Types:
Implicit coercion (automatic)
Explicit coercion (manual)
Explicit Example:
Number("10"); // 10
String(100); // "100"6. What is the difference between == and ===?
== (Loose Equality)
Compares values only
Performs type conversion
=== (Strict Equality)
Compares both value and data type
No type conversion
Example:
console.log(5 == "5"); // true
console.log(5 === "5"); // false
Best Practice:
Always prefer === to avoid unexpected results.
7. What are truthy and falsy values?
Truthy Values
Values treated as true in a boolean context.
Examples:
Non-empty strings
Non-zero numbers
Objects
Arrays
Falsy Values
JavaScript has these falsy values:
false
0
-0
0n
"" (empty string)
null
undefined
NaN
Example:
if ("Hello") {
console.log("Truthy");
}
if (0) {
console.log("Won't execute");
}8. What is undefined?
undefined means a variable has been declared but has not been assigned a value.
Example:
let value;
console.log(value);
Output:
undefinedKey Point:
undefined is assigned automatically by JavaScript.
9. What is null?
null represents an intentional absence of any object value.
It is assigned manually by the developer.
Example:
let user = null;
console.log(user);
Output:
nullDifference:
undefined โ No value assigned.
null โ Empty value assigned intentionally.
10. What is NaN?
NaN stands for Not a Number.
It represents an invalid numeric result.
โค๏ธ Double Tap For Part 2
โค13๐1
๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐๐ป-๐๐ฒ๐บ๐ฎ๐ป๐ฑ ๐ฆ๐ธ๐ถ๐น๐น๐ ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐! ๐ป๐ฅ
Want to future-proof your career without spending a single rupee? These 4 beginner-friendly FREE courses will help you build practical, job-ready skills
๐ FREE Courses Included
๐ Business Intelligence Using Excel
๐ค Generative AI for Beginners
๐ป C Programming for Beginners
๐ซ Python Interview Questions & Answers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4hSgTuW
๐ฅ Don't waitโstart learning today and unlock better career opportunities!
Want to future-proof your career without spending a single rupee? These 4 beginner-friendly FREE courses will help you build practical, job-ready skills
๐ FREE Courses Included
๐ Business Intelligence Using Excel
๐ค Generative AI for Beginners
๐ป C Programming for Beginners
๐ซ Python Interview Questions & Answers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4hSgTuW
๐ฅ Don't waitโstart learning today and unlock better career opportunities!
โค2
๐ฏ ๐ง๐ผ๐ฝ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ | ๐๐ผ๐ผ๐ธ ๐๐ฅ๐๐ ๐๐ผ๐๐ป๐๐ฒ๐น๐น๐ถ๐ป๐ด ๐ฆ๐ฒ๐๐๐ถ๐ผ๐ป ๐๐ป ๐๐ต๐ฒ๐ป๐ป๐ฎ๐ถ๐
โ
Learnfrom India's Best Mentors , Get 100% Placement Assistance
๐ซData Analytics :- https://pdlink.in/4q59ef1
โ
๐ซFullstack :- https://pdlink.in/4he12a2
โ
๐ซAI :- https://pdlink.in/4he5mpO
โ
In Today's competitive world, you need industry-relevant skills taught by the best.
โ
Learnfrom India's Best Mentors , Get 100% Placement Assistance
๐ซData Analytics :- https://pdlink.in/4q59ef1
โ
๐ซFullstack :- https://pdlink.in/4he12a2
โ
๐ซAI :- https://pdlink.in/4he5mpO
โ
In Today's competitive world, you need industry-relevant skills taught by the best.
Web Development Roadmap
|
|-- Core Basics
| |-- How the Web Works
| | |-- Client Server
| | |-- HTTP
| | |-- DNS
| |
| |-- Internet Basics
| | |-- Browsers
| | |-- Developer Tools
| | |-- Debugging
|
|-- Frontend
| |-- HTML
| | |-- Tags
| | |-- Forms
| | |-- Semantics
| |
| |-- CSS
| | |-- Selectors
| | |-- Flexbox
| | |-- Grid
| | |-- Responsive Design
| |
| |-- JavaScript
| | |-- Variables
| | |-- Arrays
| | |-- Objects
| | |-- DOM
| | |-- Fetch API
| | |-- ES6
| |
| |-- Frontend Frameworks
| | |-- React
| | |-- Vue
| | |-- Angular
| |
| |-- UI Libraries
| | |-- Tailwind
| | |-- Bootstrap
| |
| |-- State Management
| | |-- Redux
| | |-- Zustand
| | |-- Vuex
|
|-- Backend
| |-- Programming
| | |-- Node.js
| | |-- Python Django
| | |-- Java Spring Boot
| | |-- PHP Laravel
| |
| |-- Databases
| | |-- SQL
| | |-- PostgreSQL
| | |-- MySQL
| | |-- MongoDB
| |
| |-- APIs
| | |-- REST
| | |-- GraphQL
| | |-- Authentication
|
|-- DevOps Basics
| |-- Git
| |-- GitHub
| |-- CI CD
| |-- Docker
| |-- Linux Basics
|
|-- Testing
| |-- Unit Testing
| |-- Integration Testing
| |-- Jest
| |-- Cypress
|
|-- Deployment
| |-- Netlify
| |-- Vercel
| |-- AWS
| |-- Render
|
|-- Extra Skills
| |-- Web Security
| | |-- OWASP
| | |-- XSS
| | |-- CSRF
| |
| |-- Performance Optimization
| |-- Accessibility
| |-- SEO Basics
Free Resources to learn Web Development ๐๐
HTML CSS JavaScript
โข https://www.freecodecamp.org/learn/javascript-v9/
โข https://whatsapp.com/channel/0029Vaxox5i5fM5givkwsH0A
โข https://developer.mozilla.org/en-US/docs/Web
โข https://www.w3schools.com/
โข https://cssbattle.dev/
โข https://javascript.info/
โข https://whatsapp.com/channel/0029VaxfCpv2v1IqQjv6Ke0r
Frontend Projects
โข https://frontendmentor.io
โข https://whatsapp.com/channel/0029Vax4TBY9Bb62pAS3mX32
โข https://codepen.io
โข https://build-your-own.org
React
โข https://react.dev/learn
โข https://scrimba.com/learn/learnreact
Node.js Backend
โข https://nodejs.dev
โข https://www.theodinproject.com/paths/full-stack-javascript
Django
โข https://djangoproject.com
โข https://learndjango.com
Git and GitHub
โข https://learngitbranching.js.org/
โข https://docs.github.com/en
โข https://whatsapp.com/channel/0029Vawixh9IXnlk7VfY6w43
DevOps
โข https://roadmap.sh/devops
โข https://whatsapp.com/channel/0029Vb6btvg4inonBVckgD1U
โข https://docker-curriculum.com
SQL
โข https://mode.com/sql-tutorial/introduction-to-sql
โข https://t.me/mysqldata
โข https://whatsapp.com/channel/0029Vb02HXwJf05dAWeMxr0u
โข https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Deployment
โข https://vercel.com/docs
โข https://docs.netlify.com
Like for more โค๏ธ
ENJOY LEARNING ๐๐
|
|-- Core Basics
| |-- How the Web Works
| | |-- Client Server
| | |-- HTTP
| | |-- DNS
| |
| |-- Internet Basics
| | |-- Browsers
| | |-- Developer Tools
| | |-- Debugging
|
|-- Frontend
| |-- HTML
| | |-- Tags
| | |-- Forms
| | |-- Semantics
| |
| |-- CSS
| | |-- Selectors
| | |-- Flexbox
| | |-- Grid
| | |-- Responsive Design
| |
| |-- JavaScript
| | |-- Variables
| | |-- Arrays
| | |-- Objects
| | |-- DOM
| | |-- Fetch API
| | |-- ES6
| |
| |-- Frontend Frameworks
| | |-- React
| | |-- Vue
| | |-- Angular
| |
| |-- UI Libraries
| | |-- Tailwind
| | |-- Bootstrap
| |
| |-- State Management
| | |-- Redux
| | |-- Zustand
| | |-- Vuex
|
|-- Backend
| |-- Programming
| | |-- Node.js
| | |-- Python Django
| | |-- Java Spring Boot
| | |-- PHP Laravel
| |
| |-- Databases
| | |-- SQL
| | |-- PostgreSQL
| | |-- MySQL
| | |-- MongoDB
| |
| |-- APIs
| | |-- REST
| | |-- GraphQL
| | |-- Authentication
|
|-- DevOps Basics
| |-- Git
| |-- GitHub
| |-- CI CD
| |-- Docker
| |-- Linux Basics
|
|-- Testing
| |-- Unit Testing
| |-- Integration Testing
| |-- Jest
| |-- Cypress
|
|-- Deployment
| |-- Netlify
| |-- Vercel
| |-- AWS
| |-- Render
|
|-- Extra Skills
| |-- Web Security
| | |-- OWASP
| | |-- XSS
| | |-- CSRF
| |
| |-- Performance Optimization
| |-- Accessibility
| |-- SEO Basics
Free Resources to learn Web Development ๐๐
HTML CSS JavaScript
โข https://www.freecodecamp.org/learn/javascript-v9/
โข https://whatsapp.com/channel/0029Vaxox5i5fM5givkwsH0A
โข https://developer.mozilla.org/en-US/docs/Web
โข https://www.w3schools.com/
โข https://cssbattle.dev/
โข https://javascript.info/
โข https://whatsapp.com/channel/0029VaxfCpv2v1IqQjv6Ke0r
Frontend Projects
โข https://frontendmentor.io
โข https://whatsapp.com/channel/0029Vax4TBY9Bb62pAS3mX32
โข https://codepen.io
โข https://build-your-own.org
React
โข https://react.dev/learn
โข https://scrimba.com/learn/learnreact
Node.js Backend
โข https://nodejs.dev
โข https://www.theodinproject.com/paths/full-stack-javascript
Django
โข https://djangoproject.com
โข https://learndjango.com
Git and GitHub
โข https://learngitbranching.js.org/
โข https://docs.github.com/en
โข https://whatsapp.com/channel/0029Vawixh9IXnlk7VfY6w43
DevOps
โข https://roadmap.sh/devops
โข https://whatsapp.com/channel/0029Vb6btvg4inonBVckgD1U
โข https://docker-curriculum.com
SQL
โข https://mode.com/sql-tutorial/introduction-to-sql
โข https://t.me/mysqldata
โข https://whatsapp.com/channel/0029Vb02HXwJf05dAWeMxr0u
โข https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Deployment
โข https://vercel.com/docs
โข https://docs.netlify.com
Like for more โค๏ธ
ENJOY LEARNING ๐๐
โค6
๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐๐ ๐๐ผ๐ฟ ๐๐ฅ๐๐ | ๐ฑ ๐ ๐๐๐-๐ง๐ฎ๐ธ๐ฒ ๐๐ผ๐ผ๐ด๐น๐ฒ ๐๐ ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐ฅ
Artificial Intelligence is transforming every industryโand now you can learn directly from Google with 100% FREE AI courses!
๐ฏ Perfect For
๐ Students & Freshers
๐จโ๐ป Software Developers
๐ Data Analysts
๐ซ AI & Machine Learning Aspirants
๐ผ Working Professionals
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/45HWa5Q
๐ฅ Start your AI journey today and stay ahead in the era of Artificial Intelligence!
Artificial Intelligence is transforming every industryโand now you can learn directly from Google with 100% FREE AI courses!
๐ฏ Perfect For
๐ Students & Freshers
๐จโ๐ป Software Developers
๐ Data Analysts
๐ซ AI & Machine Learning Aspirants
๐ผ Working Professionals
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/45HWa5Q
๐ฅ Start your AI journey today and stay ahead in the era of Artificial Intelligence!
๐ ๐ฐ ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐ง๐ผ ๐๐ผ๐ผ๐๐ ๐ฌ๐ผ๐๐ฟ ๐ฅ๐ฒ๐๐๐บ๐ฒ๐ฅ
Add these 100% FREE certification courses to your resume and gain valuable, job-ready skills that employers look for.
โ 100% FREE Certification Courses
โ Beginner-Friendly Learning
โ Industry-Relevant Skills
โ Self-Paced Online Learning
โ Strengthen Your Resume & LinkedIn Profile
โ Improve Your Job & Internship Opportunities
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4bwkOtA
๐ฅ Invest in your skills today and give your resume the competitive edge it deserves!
Add these 100% FREE certification courses to your resume and gain valuable, job-ready skills that employers look for.
โ 100% FREE Certification Courses
โ Beginner-Friendly Learning
โ Industry-Relevant Skills
โ Self-Paced Online Learning
โ Strengthen Your Resume & LinkedIn Profile
โ Improve Your Job & Internship Opportunities
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4bwkOtA
๐ฅ Invest in your skills today and give your resume the competitive edge it deserves!
โค5
You can learn ReactJS easily ๐คฉ
Here's all you need to get started ๐
1.Components
โข Functional Components
โข Class Components
โข JSX (JavaScript XML) Syntax
2.Props (Properties)
โข Passing Props
โข Default Props
โข Prop Types
3.State
โข useState Hook
โข Class Component State
โข Immutable State
4.Lifecycle Methods (Class Components)
โข componentDidMount
โข componentDidUpdate
โข componentWillUnmount
5.Hooks (Functional Components)
โข useState
โข useEffect
โข useContext
โข useReducer
โข useCallback
โข useMemo
โข useRef
โข useImperativeHandle
โข useLayoutEffect
6.Event Handling
โข Handling Events in Functional Components
โข Handling Events in Class Components
7.Conditional Rendering
โข if Statements
โข Ternary Operators
โข Logical && Operator
8.Lists and Keys
โข Rendering Lists
โข Keys in React Lists
9.Component Composition
โข Reusing Components
โข Children Props
โข Composition vs Inheritance
10.Higher-Order Components (HOC)
โข Creating HOCs
โข Using HOCs for Reusability
11.Render Props
โข Using Render Props Pattern
12.React Router
โข <BrowserRouter>
โข <Route>
โข <Link>
โข <Switch>
โข Route Parameters
13.Navigation
โข useHistory Hook
โข useLocation Hook
State Management
14.Context API
โข Creating Context
โข useContext Hook
15.Redux
โข Actions
โข Reducers
โข Store
โข connect Function (React-Redux)
16.Forms
โข Handling Form Data
โข Controlled Components
โข Uncontrolled Components
17.Side Effects
โข useEffect for Data Fetching
โข useEffect Cleanup
18.AJAX Requests
โข Fetch API
โข Axios Library
Error Handling
19.Error Boundaries
โข componentDidCatch (Class Components)
โข ErrorBoundary Component (Functional
Components)
20.Testing
โข Jest Testing Framework
โข React Testing Library
21. Best Practices
โข Code Splitting
โข PureComponent and React.memo
โข Avoiding Reconciliation
โข Keys for Dynamic Lists
22.Optimization
โข Memoization
โข Profiling and Performance Monitoring
23. Build and Deployment
โข Create React App (CRA)
โข Production Builds
โข Deployment Strategies
Frameworks and Libraries
24.Styling Libraries
โข Styled-components
โข CSS Modules
25.State Management Libraries
โข Redux
โข MobX
26.Routing Libraries
โข React Router
โข Reach Router
React โค๏ธ for more
Web Development Projects โฌ๏ธ
https://whatsapp.com/channel/0029Vax4TBY9Bb62pAS3mX32
Web Development Jobs โฌ๏ธ
https://whatsapp.com/channel/0029Vb1raTiDjiOias5ARu2p
Here's all you need to get started ๐
1.Components
โข Functional Components
โข Class Components
โข JSX (JavaScript XML) Syntax
2.Props (Properties)
โข Passing Props
โข Default Props
โข Prop Types
3.State
โข useState Hook
โข Class Component State
โข Immutable State
4.Lifecycle Methods (Class Components)
โข componentDidMount
โข componentDidUpdate
โข componentWillUnmount
5.Hooks (Functional Components)
โข useState
โข useEffect
โข useContext
โข useReducer
โข useCallback
โข useMemo
โข useRef
โข useImperativeHandle
โข useLayoutEffect
6.Event Handling
โข Handling Events in Functional Components
โข Handling Events in Class Components
7.Conditional Rendering
โข if Statements
โข Ternary Operators
โข Logical && Operator
8.Lists and Keys
โข Rendering Lists
โข Keys in React Lists
9.Component Composition
โข Reusing Components
โข Children Props
โข Composition vs Inheritance
10.Higher-Order Components (HOC)
โข Creating HOCs
โข Using HOCs for Reusability
11.Render Props
โข Using Render Props Pattern
12.React Router
โข <BrowserRouter>
โข <Route>
โข <Link>
โข <Switch>
โข Route Parameters
13.Navigation
โข useHistory Hook
โข useLocation Hook
State Management
14.Context API
โข Creating Context
โข useContext Hook
15.Redux
โข Actions
โข Reducers
โข Store
โข connect Function (React-Redux)
16.Forms
โข Handling Form Data
โข Controlled Components
โข Uncontrolled Components
17.Side Effects
โข useEffect for Data Fetching
โข useEffect Cleanup
18.AJAX Requests
โข Fetch API
โข Axios Library
Error Handling
19.Error Boundaries
โข componentDidCatch (Class Components)
โข ErrorBoundary Component (Functional
Components)
20.Testing
โข Jest Testing Framework
โข React Testing Library
21. Best Practices
โข Code Splitting
โข PureComponent and React.memo
โข Avoiding Reconciliation
โข Keys for Dynamic Lists
22.Optimization
โข Memoization
โข Profiling and Performance Monitoring
23. Build and Deployment
โข Create React App (CRA)
โข Production Builds
โข Deployment Strategies
Frameworks and Libraries
24.Styling Libraries
โข Styled-components
โข CSS Modules
25.State Management Libraries
โข Redux
โข MobX
26.Routing Libraries
โข React Router
โข Reach Router
React โค๏ธ for more
Web Development Projects โฌ๏ธ
https://whatsapp.com/channel/0029Vax4TBY9Bb62pAS3mX32
Web Development Jobs โฌ๏ธ
https://whatsapp.com/channel/0029Vb1raTiDjiOias5ARu2p
โค5
๐ ๐๐ฅ๐๐ ๐๐ฟ๐ฒ๐๐ต๐ฒ๐ฟ ๐๐ถ๐ฟ๐ถ๐ป๐ด ๐๐ฟ๐ถ๐๐ฒ | ๐ง๐ฒ๐ฐ๐ต ๐ฅ๐ผ๐น๐ฒ๐ ๐จ๐ฝ ๐๐ผ โน๐ญ๐ฎ ๐๐ฃ๐!๐ฅ
Internship + Pre-Placement Offer
๐ผ Company: GoComet
๐ฐ Stipend: โน30,000โ35,000/Month
๐ PPO: Up to โน12 LPA
๐ Assessment Centres: Pune | Hyderabad | Noida | Chennai | Bangalore
๐ ๐๐ฝ๐ฝ๐น๐ ๐ก๐ผ๐ ๐:
Full Stack Intern:- https://pdlink.in/4z3vF8o
AI First SDET Interns :- https://pdlink.in/4hS1Am2
โณ Limited Hiring Slots Available
Internship + Pre-Placement Offer
๐ผ Company: GoComet
๐ฐ Stipend: โน30,000โ35,000/Month
๐ PPO: Up to โน12 LPA
๐ Assessment Centres: Pune | Hyderabad | Noida | Chennai | Bangalore
๐ ๐๐ฝ๐ฝ๐น๐ ๐ก๐ผ๐ ๐:
Full Stack Intern:- https://pdlink.in/4z3vF8o
AI First SDET Interns :- https://pdlink.in/4hS1Am2
โณ Limited Hiring Slots Available
โค1๐ฅฑ1
๐ ๐๐๐ ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
Upgrade your tech skills with 100% FREE IBM certification courses and build a strong foundation in AI, Data Science, Cloud Computing, SQL, Python, and Machine Learning.
๐ฏ Perfect For
๐ Students & Freshers
๐จโ๐ป Software Developers
๐ Data Analysts
๐ค AI & Data Science Aspirants
๐ผ Working Professionals
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/45KgqDR
๐ฅ Start learning today and prepare yourself for high-paying opportunities in the tech industry!
Upgrade your tech skills with 100% FREE IBM certification courses and build a strong foundation in AI, Data Science, Cloud Computing, SQL, Python, and Machine Learning.
๐ฏ Perfect For
๐ Students & Freshers
๐จโ๐ป Software Developers
๐ Data Analysts
๐ค AI & Data Science Aspirants
๐ผ Working Professionals
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/45KgqDR
๐ฅ Start learning today and prepare yourself for high-paying opportunities in the tech industry!
โค1
๐ JavaScript Interview Questions with Answers โ Part 2
11. What is the typeof operator?
The typeof operator is used to determine the data type of a value.
Example:
Important Interview Point:
Output:
This is a historical behavior in JavaScript.
12. What are template literals?
Template literals are strings created using backticks ``.
They allow you to easily embed variables and expressions using
Example:
Output:
Benefits:
Easy string interpolation
Supports multi-line strings
Allows expressions inside strings
13. What are JavaScript operators?
Operators are symbols used to perform operations on values.
Common Types:
Arithmetic:
Comparison:
Logical:
Assignment:
Example:
14. What is the ternary operator?
The ternary operator is a short way of writing an
Syntax:
Example:
Output:
Equivalent if...else:
Interview Tip: Use ternary operators for simple conditions. Avoid deeply nested ternaries because they reduce readability.
15. What is variable hoisting?
Hoisting is JavaScript's behavior of processing declarations before executing the code in their scope.
With var:
Output:
The declaration is hoisted, but the assignment happens later.
With let and const:
This results in a
Function declarations are also hoisted:
16. What is scope in JavaScript?
Scope determines where a variable can be accessed in a program.
Example:
Main Types:
Global Scope
Function Scope
Block Scope
Module Scope
Understanding scope is essential for closures and avoiding variable conflicts.
17. What are global, function, and block scope?
Global Scope
A variable declared outside functions or blocks can generally be accessed throughout the script.
Function Scope
Variables declared with
11. What is the typeof operator?
The typeof operator is used to determine the data type of a value.
Example:
console.log(typeof "Hello"); // "string"
console.log(typeof 100); // "number"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"
Important Interview Point:
console.log(typeof null);
Output:
"object" This is a historical behavior in JavaScript.
12. What are template literals?
Template literals are strings created using backticks ``.
They allow you to easily embed variables and expressions using
${}.Example:
const name = "Ajay";
const age = 25;
console.log(`My name is ${name} and I am ${age} years old.`);
Output:
My name is Ajay and I am 25 years old.Benefits:
Easy string interpolation
Supports multi-line strings
Allows expressions inside strings
13. What are JavaScript operators?
Operators are symbols used to perform operations on values.
Common Types:
Arithmetic:
+ - * / % **Comparison:
== === != !== > < >= <=Logical:
&& || !Assignment:
= += -= *= /=Example:
const a = 10;
const b = 5;
console.log(a + b); // 15
console.log(a > b); // true
14. What is the ternary operator?
The ternary operator is a short way of writing an
if...else statement.Syntax:
condition ? valueIfTrue : valueIfFalse;
Example:
const age = 20;
const result = age >= 18 ? "Adult" : "Minor";
console.log(result);
Output:
AdultEquivalent if...else:
if (age >= 18) {
result = "Adult";
} else {
result = "Minor";
}Interview Tip: Use ternary operators for simple conditions. Avoid deeply nested ternaries because they reduce readability.
15. What is variable hoisting?
Hoisting is JavaScript's behavior of processing declarations before executing the code in their scope.
With var:
console.log(x);
var x = 10;
Output:
undefined The declaration is hoisted, but the assignment happens later.
With let and const:
console.log(x);
let x = 10;
This results in a
ReferenceError. let and const are hoisted but remain in the Temporal Dead Zone (TDZ) until their declaration is reached.Function declarations are also hoisted:
greet();
function greet() {
console.log("Hello");
}
16. What is scope in JavaScript?
Scope determines where a variable can be accessed in a program.
Example:
function test() {
let message = "Hello";
console.log(message);
}
test();message is accessible inside the function but not outside it.Main Types:
Global Scope
Function Scope
Block Scope
Module Scope
Understanding scope is essential for closures and avoiding variable conflicts.
17. What are global, function, and block scope?
Global Scope
A variable declared outside functions or blocks can generally be accessed throughout the script.
let name = "Deepak";
function greet() {
console.log(name);
}
Function Scope
Variables declared with
var inside a function are accessible throughout that function.โค3
function test() {
var age = 25;
console.log(age);
}age
cannot be accessed outside
test()
.
Block Scope
let
and
const
are block-scoped.
if (true) {
let x = 10;
const y = 20;
console.log(x, y);
}x
and
y
cannot be accessed outside the
if
block.
18. What is strict mode ("use strict")?
Strict mode enables a stricter set of JavaScript rules and helps catch certain programming mistakes.
Example:
"use strict";
x = 10;
This produces a
ReferenceError
because
x
was not declared.
Without strict mode, older JavaScript behavior could create a global variable in some situations.
Benefits:
Catches common mistakes
Prevents accidental global variables
Makes some unsafe operations throw errors
Helps write cleaner code
19. What are comments in JavaScript?
Comments are text ignored by the JavaScript engine. They are used to explain code or temporarily disable code.
Single-Line Comment:
// This is a comment
console.log("Hello");
Multi-Line Comment:
/*
This is a
multi-line comment
*/
console.log("Hello");
Why Use Comments?
โ Explain complex logic
โ Improve code readability
โ Help other developers understand the code
โ Document important decisions
20. What are JavaScript modules?
Modules allow you to split JavaScript code into separate, reusable files.
They help organize large applications and prevent unnecessary global variables.
Export:
// math.js
export function add(a, b) {
return a + b;
}
Import:
// app.js
import { add } from "./math.js";
console.log(add(10, 20));
Types of Exports:
Named exports
Default exports
Default Export:
export default function greet() {
console.log("Hello");
}Important Interview Point:
ES Modules use
import
and
export
. They are the standard module system for modern JavaScript.
โค๏ธ Double Tap For Part 3
โค11
๐ JavaScript Interview Questions with Answers โ Part 4
31. How do you create objects in JavaScript?
There are several ways to create objects in JavaScript.
1. Object Literal
2. new Object()
3. Constructor Function
4. Class
Interview Tip:
Object literals are usually preferred for simple objects, while classes or constructor functions are useful when creating many similar objects.
32. What is object destructuring?
Object destructuring allows you to extract properties from an object and store them in variables.
Example:
Output:
John
25
Rename Variables:
Default Value:
33. What is the spread operator (...)?
The spread operator expands the elements of an iterable or properties of an object.
Array Example:
Output:
[1, 2, 3, 4, 5]
Object Example:
Common Uses:
โ Copy arrays
โ Merge arrays
โ Copy objects
โ Merge objects
โ Pass values to functions
34. What is the rest operator?
The rest operator (...) collects multiple values into a single array or object.
Example:
Output: 60
Here,
Important Interview Point:
The same
Spread โ expands values:
Rest โ collects values:
35. What are default parameters?
Default parameters allow you to provide a default value when an argument is not passed or is undefined.
Example:
Output: Hello Guest
If a value is provided:
Multiple Defaults:
36. What is optional chaining (?. )
Optional chaining allows you to safely access nested properties without throwing an error when an intermediate value is null or undefined.
Without Optional Chaining:
With Optional Chaining:
31. How do you create objects in JavaScript?
There are several ways to create objects in JavaScript.
1. Object Literal
const user = {
name: "John",
age: 25
};2. new Object()
const user = new Object();
user.name = "Frey";
user.age = 35;
3. Constructor Function
function User(name, age) {
this.name = name;
this.age = age;
}
const user = new User("John", 25);4. Class
class User {
constructor(name, age) {
this.name = name;
this.age = age;
}
}
const user = new User("John", 25);Interview Tip:
Object literals are usually preferred for simple objects, while classes or constructor functions are useful when creating many similar objects.
32. What is object destructuring?
Object destructuring allows you to extract properties from an object and store them in variables.
Example:
const user = {
name: "John",
age: 25,
city: "New York"
};
const { name, age } = user;
console.log(name);
console.log(age);Output:
John
25
Rename Variables:
const { name: userName } = user;
console.log(userName);Default Value:
const { country = "India" } = user;
console.log(country);33. What is the spread operator (...)?
The spread operator expands the elements of an iterable or properties of an object.
Array Example:
const numbers = [1, 2, 3];
const newNumbers = [...numbers, 4, 5];
console.log(newNumbers);
Output:
[1, 2, 3, 4, 5]
Object Example:
const user = {
name: "John",
age: 25
};
const updatedUser = {
...user,
city: "New York"
};Common Uses:
โ Copy arrays
โ Merge arrays
โ Copy objects
โ Merge objects
โ Pass values to functions
34. What is the rest operator?
The rest operator (...) collects multiple values into a single array or object.
Example:
function sum(...numbers) {
return numbers.reduce((total, num) => total + num, 0);
}
console.log(sum(10, 20, 30));Output: 60
Here,
...numbers collects all arguments into an array.Important Interview Point:
The same
... syntax has different purposes:Spread โ expands values:
const arr2 = [...arr1];Rest โ collects values:
function test(...args) {} 35. What are default parameters?
Default parameters allow you to provide a default value when an argument is not passed or is undefined.
Example:
function greet(name = "Guest") {
console.log(`Hello ${name}`);
}
greet();Output: Hello Guest
If a value is provided:
greet("Deepika"); โ Hello Deepika Multiple Defaults:
function createUser(name = "Guest", age = 18) {
console.log(name, age);
}36. What is optional chaining (?. )
Optional chaining allows you to safely access nested properties without throwing an error when an intermediate value is null or undefined.
Without Optional Chaining:
const user = {};
console.log(user.address.city); // ErrorWith Optional Chaining:
console.log(user.address?.city); // undefined
โค1
Example with Function:
The function is called only if
Common Use: Very useful when working with API responses where some properties may be missing.
37. What is nullish coalescing (??)
The nullish coalescing operator returns the right-hand value when the left-hand value is null or undefined.
Example:
Output: Guest
Important Difference From ||
Interview Tip: Use
38. What are object methods?
An object method is a function stored as a property of an object.
Example:
Output: Hello Deepak
Another Example:
39. What is method chaining?
Method chaining means calling multiple methods one after another on the same object or result.
Example:
Output: TPIRCSAVAJ
Array Example:
Output: [20,40]
Common Uses: Array processing, String manipulation, Promise chains, Libraries such as jQuery
40. What is object freezing and sealing?
JavaScript provides
Object.freeze()
Prevents: Adding properties, Removing properties, Changing existing properties
Object.seal()
Prevents: Adding properties, Removing properties
But existing properties can still be modified.
Key Difference:
Object.freeze(): Cannot add, delete, or modify properties
Object.seal(): Cannot add or delete properties, but can modify existing ones
๐ฅ Interview Tip: Both methods are shallow โ nested objects can still be modified unless they are separately frozen/sealed.
โค๏ธ Double Tap For Part 5
user.getName?.();The function is called only if
getName exists and is callable.Common Use: Very useful when working with API responses where some properties may be missing.
37. What is nullish coalescing (??)
The nullish coalescing operator returns the right-hand value when the left-hand value is null or undefined.
Example:
const username = null;
console.log(username ?? "Guest");
Output: Guest
Important Difference From ||
|| considers all falsy values: console.log(0 || 100); โ 100?? only checks null and undefined: console.log(0 ?? 100); โ 0 Interview Tip: Use
?? when 0, false, or "" are valid values that should not be replaced.38. What are object methods?
An object method is a function stored as a property of an object.
Example:
const user = {
name: "Deepak",
greet() {
console.log(`Hello ${this.name}`);
}
};
user.greet();Output: Hello Deepak
Another Example:
const calculator = {
add(a, b) { return a + b; },
multiply(a, b) { return a * b; }
};
console.log(calculator.add(10, 20));39. What is method chaining?
Method chaining means calling multiple methods one after another on the same object or result.
Example:
const result = "javascript"
.toUpperCase()
.split("")
.reverse()
.join("");
console.log(result);
Output: TPIRCSAVAJ
Array Example:
const result = [1, 2, 3, 4, 5]
.filter(num => num % 2 === 0)
.map(num => num * 10);
console.log(result);
Output: [20,40]
Common Uses: Array processing, String manipulation, Promise chains, Libraries such as jQuery
40. What is object freezing and sealing?
JavaScript provides
Object.freeze() and Object.seal() to restrict modifications to objects.Object.freeze()
Prevents: Adding properties, Removing properties, Changing existing properties
const user = { name: "Deepak", age: 25 };
Object.freeze(user);
user.age = 30;
user.city = "Pune";
console.log(user); // unchangedObject.seal()
Prevents: Adding properties, Removing properties
But existing properties can still be modified.
const user = { name: "Deepak", age: 25 };
Object.seal(user);
user.age = 30;
console.log(user.age); // 30Key Difference:
Object.freeze(): Cannot add, delete, or modify properties
Object.seal(): Cannot add or delete properties, but can modify existing ones
๐ฅ Interview Tip: Both methods are shallow โ nested objects can still be modified unless they are separately frozen/sealed.
โค๏ธ Double Tap For Part 5
โค3
๐ JavaScript Interview Questions with Answers โ Part 5
41. How do arrays work in JavaScript?
An array is an ordered collection of values. JS arrays can hold different data types and use zero-based indexing.
Example:
Important Points:
โข Index starts at 0
โข Arrays are objects in JavaScript
โข Arrays can grow or shrink dynamically
โข Arrays can contain mixed data types
42. What is the difference between map() and forEach()?
Both iterate over an array, but used differently.
map()
Creates and returns a new array.
forEach()
Executes a function for each element but does not return a new array.
Key Difference:
โข map(): Returns a new array. Used for transformation. Can be chained.
โข forEach(): Returns undefined. Used for side effects.
43. What is filter()?
Creates a new array with elements that pass a condition. Original array is not modified.
Example:
44. What is reduce()?
Processes an array and produces a single accumulated value.
Example:
Common Uses: Calculate totals, averages, count items, group data, build objects.
Interview Tip: Understand the accumulator and current value arguments.
45. What is find()?
Returns the first element that satisfies a condition. Returns undefined if none match.
Example:
find() vs filter(): find = first match, filter = all matches.
46. What is findIndex()?
Returns the index of the first element that satisfies a condition. Returns -1 if none match.
Example:
47. What is some()?
Checks if at least one element satisfies a condition. Returns Boolean.
Example:
48. What is every()?
Checks if all elements satisfy a condition. Returns Boolean.
Example:
some() vs every(): some = at least one, every = all.
49. What is the difference between slice() and splice()?
slice()
Returns a portion without modifying the original.
splice()
Adds, removes, or replaces elements and modifies the original.
41. How do arrays work in JavaScript?
An array is an ordered collection of values. JS arrays can hold different data types and use zero-based indexing.
Example:
const items = ["Apple", 25, true];
console.log(items[0]); // Apple
console.log(items.length); // 3
Important Points:
โข Index starts at 0
โข Arrays are objects in JavaScript
โข Arrays can grow or shrink dynamically
โข Arrays can contain mixed data types
42. What is the difference between map() and forEach()?
Both iterate over an array, but used differently.
map()
Creates and returns a new array.
const numbers = [1, 2, 3];
const doubled = numbers.map(num => num * 2); // [2, 4, 6]
forEach()
Executes a function for each element but does not return a new array.
numbers.forEach(num => console.log(num * 2));
Key Difference:
โข map(): Returns a new array. Used for transformation. Can be chained.
โข forEach(): Returns undefined. Used for side effects.
43. What is filter()?
Creates a new array with elements that pass a condition. Original array is not modified.
Example:
const numbers = [1, 2, 3, 4, 5];
const evenNumbers = numbers.filter(num => num % 2 === 0); // [2, 4]
44. What is reduce()?
Processes an array and produces a single accumulated value.
Example:
const numbers = [10, 20, 30];
const total = numbers.reduce((sum, num) => sum + num, 0); // 60
Common Uses: Calculate totals, averages, count items, group data, build objects.
Interview Tip: Understand the accumulator and current value arguments.
45. What is find()?
Returns the first element that satisfies a condition. Returns undefined if none match.
Example:
const numbers = [10, 20, 30, 40];
const result = numbers.find(num => num > 20); // 30
find() vs filter(): find = first match, filter = all matches.
46. What is findIndex()?
Returns the index of the first element that satisfies a condition. Returns -1 if none match.
Example:
const numbers = [10, 20, 30, 40];
const index = numbers.findIndex(num => num > 20); // 2
47. What is some()?
Checks if at least one element satisfies a condition. Returns Boolean.
Example:
const numbers = [1, 3, 5, 8];
const result = numbers.some(num => num % 2 === 0); // true
48. What is every()?
Checks if all elements satisfy a condition. Returns Boolean.
Example:
const numbers = [2, 4, 6, 8];
const result = numbers.every(num => num % 2 === 0); // true
some() vs every(): some = at least one, every = all.
49. What is the difference between slice() and splice()?
slice()
Returns a portion without modifying the original.
const numbers = [1, 2, 3, 4, 5];
const result = numbers.slice(1, 4); // [2, 3, 4]
splice()
Adds, removes, or replaces elements and modifies the original.
const numbers = [1, 2, 3, 4, 5];
numbers.splice(1, 2); // removes 2 elements at index 1
console.log(numbers); // [1, 4, 5]
โค5๐2
Key Difference:
โข slice(): Does not modify original. Extracts elements. Returns copied portion.
โข splice(): Modifies original. Adds/removes/replaces. Returns removed elements.
50. What are push(), pop(), shift(), and unshift()?
Methods that modify arrays.
โข push(): Add to END โ
โข pop(): Remove from END โ
โข unshift(): Add to START โ
โข shift(): Remove from START โ
Quick Memory Trick:
push/pop = END, unshift/shift = START
โค๏ธ Double Tap For Part 6
โข slice(): Does not modify original. Extracts elements. Returns copied portion.
โข splice(): Modifies original. Adds/removes/replaces. Returns removed elements.
50. What are push(), pop(), shift(), and unshift()?
Methods that modify arrays.
โข push(): Add to END โ
arr.push(3) โข pop(): Remove from END โ
arr.pop() โข unshift(): Add to START โ
arr.unshift(0) โข shift(): Remove from START โ
arr.shift() Quick Memory Trick:
push/pop = END, unshift/shift = START
โค๏ธ Double Tap For Part 6
โค2
โ
JavaScript Acronyms You MUST Know ๐ป๐ฅ
JS โ JavaScript
ES โ ECMAScript
DOM โ Document Object Model
BOM โ Browser Object Model
JSON โ JavaScript Object Notation
AJAX โ Asynchronous JavaScript And XML
API โ Application Programming Interface
SPA โ Single Page Application
MPA โ Multi Page Application
SSR โ Server Side Rendering
CSR โ Client Side Rendering
TS โ TypeScript
NPM โ Node Package Manager
NPX โ Node Package Execute
CDN โ Content Delivery Network
IIFE โ Immediately Invoked Function Expression
HOF โ Higher Order Function
MVC โ Model View Controller
MVVM โ Model View ViewModel
V8 โ Google JavaScript Engine
REPL โ Read Evaluate Print Loop
CORS โ Cross Origin Resource Sharing
JWT โ JSON Web Token
SSE โ Server Sent Events
WS โ WebSocket
๐ฌ Double Tap โฅ๏ธ For More ๐
JS โ JavaScript
ES โ ECMAScript
DOM โ Document Object Model
BOM โ Browser Object Model
JSON โ JavaScript Object Notation
AJAX โ Asynchronous JavaScript And XML
API โ Application Programming Interface
SPA โ Single Page Application
MPA โ Multi Page Application
SSR โ Server Side Rendering
CSR โ Client Side Rendering
TS โ TypeScript
NPM โ Node Package Manager
NPX โ Node Package Execute
CDN โ Content Delivery Network
IIFE โ Immediately Invoked Function Expression
HOF โ Higher Order Function
MVC โ Model View Controller
MVVM โ Model View ViewModel
V8 โ Google JavaScript Engine
REPL โ Read Evaluate Print Loop
CORS โ Cross Origin Resource Sharing
JWT โ JSON Web Token
SSE โ Server Sent Events
WS โ WebSocket
๐ฌ Double Tap โฅ๏ธ For More ๐
โค15๐ฅ4
๐ Full Stack Projects You Should Build (With Source Code)
1๏ธโฃ AI SaaS Tool
Learn authentication, subscriptions, APIs & AI integration.
๐ Source Code: https://github.com/ayusshrathore/ai-saas
2๏ธโฃ Real-Time Collaborative Code Editor
Just like Google Docs but for coding. Multiple users can edit code simultaneously.
๐ Source Code: https://github.com/Mohitur669/Realtime-Collaborative-Code-Editor
3๏ธโฃ Trading Simulator
A virtual stock trading platform to practice trading strategies.
๐ Source Code: https://github.com/nikolatechie/trading-simulator
4๏ธโฃ Microservices E-Commerce Platform
Learn scalable architecture using microservices, APIs, and backend systems.
๐ Source Code: https://github.com/ShahandFahad/E-Commerce
5๏ธโฃ Real-Time Chat Application
Build a WhatsApp-like chat app with real-time messaging.
๐ Tutorial + Code: https://youtu.be/B_l8nD-bvI0?si=M4N5p1wiPiBW-XA8
6๏ธโฃ Developer Portfolio SaaS
Create a platform where developers can generate their own portfolio websites.
๐ Source Code: https://github.com/akhilub/portfolio-saas
7๏ธโฃ Job Referral Platform
A platform where users can request and provide job referrals.
๐ Source Code: https://github.com/RutikKulkarni/ReferralNetworkHub
8๏ธโฃ Food Delivery App
Build your own Swiggy/Zomato-like full stack application.
๐ Source Code: https://github.com/Mshandev/Food-Delivery
9๏ธโฃ Ride Sharing App
Learn how ride booking systems like Uber work.
๐ Source Code: https://github.com/codinggita/ride_share
๐ Video Streaming Platform
Build your own YouTube-like video streaming platform.
๐ Source Code: https://github.com/soumanpaul/Video-streaming-web-app
โจ Donโt forget to react to this message for more awesome content like this! ๐
๐ Thank you all for joining! ๐
1๏ธโฃ AI SaaS Tool
Learn authentication, subscriptions, APIs & AI integration.
๐ Source Code: https://github.com/ayusshrathore/ai-saas
2๏ธโฃ Real-Time Collaborative Code Editor
Just like Google Docs but for coding. Multiple users can edit code simultaneously.
๐ Source Code: https://github.com/Mohitur669/Realtime-Collaborative-Code-Editor
3๏ธโฃ Trading Simulator
A virtual stock trading platform to practice trading strategies.
๐ Source Code: https://github.com/nikolatechie/trading-simulator
4๏ธโฃ Microservices E-Commerce Platform
Learn scalable architecture using microservices, APIs, and backend systems.
๐ Source Code: https://github.com/ShahandFahad/E-Commerce
5๏ธโฃ Real-Time Chat Application
Build a WhatsApp-like chat app with real-time messaging.
๐ Tutorial + Code: https://youtu.be/B_l8nD-bvI0?si=M4N5p1wiPiBW-XA8
6๏ธโฃ Developer Portfolio SaaS
Create a platform where developers can generate their own portfolio websites.
๐ Source Code: https://github.com/akhilub/portfolio-saas
7๏ธโฃ Job Referral Platform
A platform where users can request and provide job referrals.
๐ Source Code: https://github.com/RutikKulkarni/ReferralNetworkHub
8๏ธโฃ Food Delivery App
Build your own Swiggy/Zomato-like full stack application.
๐ Source Code: https://github.com/Mshandev/Food-Delivery
9๏ธโฃ Ride Sharing App
Learn how ride booking systems like Uber work.
๐ Source Code: https://github.com/codinggita/ride_share
๐ Video Streaming Platform
Build your own YouTube-like video streaming platform.
๐ Source Code: https://github.com/soumanpaul/Video-streaming-web-app
โจ Donโt forget to react to this message for more awesome content like this! ๐
๐ Thank you all for joining! ๐
โค9๐ฅ1
๐ JavaScript Interview Questions with Answers โ Part 6
51. How do you sort arrays?
The
Sorting Strings
Output:
Sorting Numbers
By default,
Output:
Descending Order:
Interview Tip:
52. What is array destructuring?
Array destructuring allows you to extract values from an array and assign them to variables.
Example:
Output:
10
20
30
Skipping Values:
Output:
10 30
Default Values:
Output:
10 20
53. What are Sets?
A
Duplicate values are automatically removed.
Example:
The Set contains:
Common Methods:
Convert Set to Array:
54. What are Maps?
A
Unlike regular objects, a
Example:
Output:
Deepak
Common Methods:
Example:
Output:
true
Map vs Object:
Map
โข Any value can be a key
โข Has size property
โข Built-in methods
โข Designed for key-value collections
Object
โข Keys are primarily strings/symbols
โข No built-in size
โข Different object APIs
โข General-purpose objects
55. What are Symbols?
Example:
Output:
false
Even though both have the same description, each
Using Symbol as an Object Property:
Common Use:
56. What are generators?
Generators are special functions that can pause and resume execution.
They are created using
Example:
51. How do you sort arrays?
The
sort() method is used to sort the elements of an array.Sorting Strings
const fruits = ["Banana", "Apple", "Mango"];
fruits.sort();
console.log(fruits);
Output:
["Apple", "Banana", "Mango"]Sorting Numbers
By default,
sort() converts elements to strings, so a comparison function should be used for numbers.const numbers = [10, 5, 20, 2];
numbers.sort((a, b) => a - b);
console.log(numbers);
Output:
[2, 5, 10, 20]Descending Order:
numbers.sort((a, b) => b - a);
Interview Tip:
sort() mutates the original array.52. What is array destructuring?
Array destructuring allows you to extract values from an array and assign them to variables.
Example:
const numbers = [10, 20, 30];
const [a, b, c] = numbers;
console.log(a);
console.log(b);
console.log(c);
Output:
10
20
30
Skipping Values:
const numbers = [10, 20, 30];
const [first, , third] = numbers;
console.log(first, third);
Output:
10 30
Default Values:
const numbers = [10];
const [a, b = 20] = numbers;
console.log(a, b);
Output:
10 20
53. What are Sets?
A
Set is a collection of unique values.Duplicate values are automatically removed.
Example:
const numbers = new Set([1, 2, 2, 3, 3]);
console.log(numbers);
The Set contains:
{1, 2, 3}Common Methods:
const numbers = new Set();
numbers.add(10);
numbers.add(20);
console.log(numbers.has(10));
numbers.delete(20);
Convert Set to Array:
const arr = [...numbers];
54. What are Maps?
A
Map is a collection of key-value pairs.Unlike regular objects, a
Map can use different data types as keys.Example:
const users = new Map();
users.set(1, "Deepak");
users.set(2, "John");
console.log(users.get(1));
Output:
Deepak
Common Methods:
users.set(key, value);
users.get(key);
users.has(key);
users.delete(key);
users.clear();
Example:
console.log(users.has(2));
Output:
true
Map vs Object:
Map
โข Any value can be a key
โข Has size property
โข Built-in methods
โข Designed for key-value collections
Object
โข Keys are primarily strings/symbols
โข No built-in size
โข Different object APIs
โข General-purpose objects
55. What are Symbols?
Symbol is a primitive data type used to create unique identifiers.Example:
const id1 = Symbol("id");
const id2 = Symbol("id");
console.log(id1 === id2);Output:
false
Even though both have the same description, each
Symbol is unique.Using Symbol as an Object Property:
const id = Symbol("id");
const user = {
name: "Deepak",
[id]: 101
};
console.log(user[id]);Common Use:
Symbols are useful when you need unique property keys that are unlikely to conflict with other properties.56. What are generators?
Generators are special functions that can pause and resume execution.
They are created using
function* and use the yield keyword.Example:
โค3
function* numbers() {
yield 1;
yield 2;
yield 3;
}
const generator = numbers();
console.log(generator.next());
console.log(generator.next());Output:
{ value: 1, done: false }{ value: 2, done: false }After all values are consumed:
{ value: 3, done: false }{ value: undefined, done: true }Important:
Calling a generator function doesn't immediately execute its body. It returns a generator object.
57. What are iterators?
An iterator is an object that provides a way to access values one at a time using the
next() method.Example:
const numbers = [10, 20, 30];
const iterator = numbers[Symbol.iterator]();
console.log(iterator.next());
console.log(iterator.next());
Output:
{ value: 10, done: false }{ value: 20, done: false }The iterator eventually returns:
{ value: undefined, done: true }Common Iterables:
โข Arrays
โข Strings
โข Maps
โข Sets
That's why they can be used with
for...of.for (const number of numbers) {
console.log(number);
}58. What is destructuring assignment?
Destructuring assignment allows values to be extracted from arrays or objects and assigned to variables.
Object Example:
const user = {
name: "Deepak",
age: 25
};
const { name, age } = user;Array Example:
const numbers = [10, 20];
const [a, b] = numbers;
Why Use It?
It makes code shorter and easier to read, especially when working with API responses and function parameters.
59. What is dynamic import?
Dynamic import allows a JavaScript module to be loaded when it is needed, instead of loading it immediately.
It uses:
import()Example:
async function loadModule() {
const module = await import("./math.js");
console.log(module.add(10, 20));
}Important:
Unlike a static import:
import { add } from "./math.js";dynamic imports return a Promise.
Common Uses:
โข Lazy loading
โข Code splitting
โข Loading features only when required
โข Improving initial page performance
60. What are ES6 modules?
ES6 modules provide a standard way to divide JavaScript applications into separate files.
They use
export and import.Export:
// math.js
export function add(a, b) {
return a + b;
}
Import:
// app.js
import { add } from "./math.js";
console.log(add(10, 20));
Default Export:
export default function greet() {
console.log("Hello");
}Import:
import greet from "./greet.js";
Benefits:
โ Code organization
โ Reusability
โ Encapsulation
โ Easier maintenance
โ Avoids unnecessary global variables
โค๏ธ Double Tap For Part 7
โค3๐1
๐ JavaScript Interview Questions with Answers โ Part 8
71. What is fetch()?
It returns a Promise.
Example:
Using async/await:
Interview Tip:
72. What is AJAX?
AJAX stands for Asynchronous JavaScript and XML.
It is a technique for communicating with a server and updating parts of a webpage without reloading the entire page.
Despite the name, AJAX doesn't require XML. Modern applications commonly exchange JSON.
Example:
A webpage can request:
Modern Approach:
Today,
73. What are Web APIs?
Web APIs are browser-provided interfaces that allow JavaScript to interact with browser features and the environment.
Examples include:
โข
โข
โข DOM APIs
โข Local Storage
โข Geolocation API
โข Web Workers
โข Clipboard API
Example:
The timer functionality is provided by the host environment, such as a browser or Node.js runtime, rather than being part of the JavaScript language itself.
Interview Tip:
Don't confuse JavaScript language features with browser Web APIs.
74. What is setTimeout()?
Example:
The callback becomes eligible to run after approximately 2 seconds.
Important:
The delay is not a guarantee that the function executes exactly at that time.
It may execute later if the JavaScript runtime is busy.
75. What is setInterval()?
Example:
The callback runs approximately every second until the interval is cancelled.
Stop It:
Common Uses:
โข Timers
โข Polling
โข Repeated UI updates
โข Periodic tasks
76. What is clearTimeout()?
Example:
The callback will not execute because the timeout was cancelled before it became eligible to run.
Common Use:
Useful when you need to cancel a scheduled action.
77. What is clearInterval()?
Example:
71. What is fetch()?
fetch() is a modern JavaScript API used to make HTTP requests and communicate with servers.It returns a Promise.
Example:
fetch("https://api.example.com/users")
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.log(error);
});Using async/await:
async function getUsers() {
try {
const response = await fetch(
"https://api.example.com/users"
);
const data = await response.json();
console.log(data);
} catch (error) {
console.log(error);
}
}Interview Tip:
fetch() rejects its Promise for network-level failures, but an HTTP error such as 404 or 500 does not automatically reject it. You should check response.ok.72. What is AJAX?
AJAX stands for Asynchronous JavaScript and XML.
It is a technique for communicating with a server and updating parts of a webpage without reloading the entire page.
Despite the name, AJAX doesn't require XML. Modern applications commonly exchange JSON.
Example:
A webpage can request:
User data โ Server
โ
JSON
โ
JavaScript
โ
Update webpage
Modern Approach:
Today,
fetch() is commonly used instead of the older XMLHttpRequest API.73. What are Web APIs?
Web APIs are browser-provided interfaces that allow JavaScript to interact with browser features and the environment.
Examples include:
โข
fetch()โข
setTimeout()โข DOM APIs
โข Local Storage
โข Geolocation API
โข Web Workers
โข Clipboard API
Example:
setTimeout(() => {
console.log("Hello");
}, 1000);The timer functionality is provided by the host environment, such as a browser or Node.js runtime, rather than being part of the JavaScript language itself.
Interview Tip:
Don't confuse JavaScript language features with browser Web APIs.
74. What is setTimeout()?
setTimeout() schedules a function to run after a specified delay.Example:
setTimeout(() => {
console.log("Hello");
}, 2000);The callback becomes eligible to run after approximately 2 seconds.
Important:
The delay is not a guarantee that the function executes exactly at that time.
It may execute later if the JavaScript runtime is busy.
75. What is setInterval()?
setInterval() repeatedly schedules a function at approximately specified intervals.Example:
const interval = setInterval(() => {
console.log("Running...");
}, 1000);The callback runs approximately every second until the interval is cancelled.
Stop It:
clearInterval(interval);
Common Uses:
โข Timers
โข Polling
โข Repeated UI updates
โข Periodic tasks
76. What is clearTimeout()?
clearTimeout() cancels a timeout that was previously scheduled using setTimeout().Example:
const timer = setTimeout(() => {
console.log("Hello");
}, 5000);
clearTimeout(timer);The callback will not execute because the timeout was cancelled before it became eligible to run.
Common Use:
Useful when you need to cancel a scheduled action.
77. What is clearInterval()?
clearInterval() stops an interval created using setInterval().Example:
โค2