Master Git & GitHub: From Basics to Advanced
https://codeswithpayal.hashnode.dev/git-and-github-commands-a-comprehensive-guide-from-basic-to-advanced
https://codeswithpayal.hashnode.dev/git-and-github-commands-a-comprehensive-guide-from-basic-to-advanced
Technologies: Tools & Tips | Expert Guides on Latest Tech Tools
Master Git & GitHub: From Basics to Advanced
Learn essential Git and GitHub commands with this comprehensive guide covering basic to advanced techniques for efficient source code management
Today, let's understand another programming concept:
π₯ Data Structures
This is one of the most important topics for coding interviews.
π¦ What is a Data Structure?
A Data Structure is a way of organizing and storing data efficiently so it can be:
β’ accessed quickly
β’ modified easily
β’ processed effectively
π Choosing the right data structure can optimize performance significantly.
π§ Types of Data Structures
1οΈβ£ Linear Data Structures
Elements are arranged sequentially
β’ Array
β Fixed size
β Fast access using index
β Example use: storing marks
β’ Linked List
β Elements connected via pointers
β Dynamic size
β Slower access, faster insertion
β’ Stack (LIFO)
β Last In First Out
β Operations: push, pop
β π Example: Undo feature
β’ Queue (FIFO)
β First In First Out
β π Example: Ticket system
2οΈβ£ Non-Linear Data Structures
Elements are arranged hierarchically
β’ π³ Tree
β Parent-child structure
β Used in databases, file systems
β’ π Graph
β Nodes connected via edges
β Used in networks, maps
β‘ Key Operations
Every data structure supports:
β’ Insertion
β’ Deletion
β’ Traversal
β’ Searching
β’ Sorting
π― When to Use What
Problem Type β Data Structure
β’ Fast lookup β HashMap
β’ Ordered data β Array / List
β’ Undo operations β Stack
β’ Scheduling β Queue
β’ Hierarchical data β Tree
β’ Network problems β Graph
β οΈ Common Interview Mistakes
β’ β Using wrong data structure
β’ β Ignoring time complexity
β’ β Not considering edge cases
β’ β Overcomplicating solution
β Real-World Usage
Data structures are used in:
β’ Databases
β’ Search engines
β’ Social networks
β’ Navigation systems
β’ Machine learning
π§ Important Interview Questions
β’ Difference between Array Linked List
β’ Stack vs Queue
β’ What is HashMap?
β’ Tree traversal types
β’ BFS vs DFS
Double Tap β€οΈ For More
π₯ Data Structures
This is one of the most important topics for coding interviews.
π¦ What is a Data Structure?
A Data Structure is a way of organizing and storing data efficiently so it can be:
β’ accessed quickly
β’ modified easily
β’ processed effectively
π Choosing the right data structure can optimize performance significantly.
π§ Types of Data Structures
1οΈβ£ Linear Data Structures
Elements are arranged sequentially
β’ Array
β Fixed size
β Fast access using index
β Example use: storing marks
β’ Linked List
β Elements connected via pointers
β Dynamic size
β Slower access, faster insertion
β’ Stack (LIFO)
β Last In First Out
β Operations: push, pop
β π Example: Undo feature
β’ Queue (FIFO)
β First In First Out
β π Example: Ticket system
2οΈβ£ Non-Linear Data Structures
Elements are arranged hierarchically
β’ π³ Tree
β Parent-child structure
β Used in databases, file systems
β’ π Graph
β Nodes connected via edges
β Used in networks, maps
β‘ Key Operations
Every data structure supports:
β’ Insertion
β’ Deletion
β’ Traversal
β’ Searching
β’ Sorting
π― When to Use What
Problem Type β Data Structure
β’ Fast lookup β HashMap
β’ Ordered data β Array / List
β’ Undo operations β Stack
β’ Scheduling β Queue
β’ Hierarchical data β Tree
β’ Network problems β Graph
β οΈ Common Interview Mistakes
β’ β Using wrong data structure
β’ β Ignoring time complexity
β’ β Not considering edge cases
β’ β Overcomplicating solution
β Real-World Usage
Data structures are used in:
β’ Databases
β’ Search engines
β’ Social networks
β’ Navigation systems
β’ Machine learning
π§ Important Interview Questions
β’ Difference between Array Linked List
β’ Stack vs Queue
β’ What is HashMap?
β’ Tree traversal types
β’ BFS vs DFS
Double Tap β€οΈ For More
Javascript Functions
part 1 π
https://youtu.be/TIwB3enuWcw?si=ZwjqbCHrmccv--bv
part -2 : π
https://youtu.be/4HnYBDeFyQk?si=GrL83Wmk2MGKNvEC
part - 3 π
https://youtu.be/xm4luSKeYCc?si=R14S8GcszoSX3XDS
part 1 π
https://youtu.be/TIwB3enuWcw?si=ZwjqbCHrmccv--bv
part -2 : π
https://youtu.be/4HnYBDeFyQk?si=GrL83Wmk2MGKNvEC
part - 3 π
https://youtu.be/xm4luSKeYCc?si=R14S8GcszoSX3XDS
YouTube
Master JavaScript Functions in Hindi (Part1) | Learn Declaration, Expression, Arrow Function & Scope
π Welcome to Knowledge Factory 22!
In this video, you will learn JavaScript Functions in Hindi step by step with practical coding examples. This is Part 1 of our JavaScript Functions Tutorial Series, designed for beginners, freshers, and advanced learnersβ¦
In this video, you will learn JavaScript Functions in Hindi step by step with practical coding examples. This is Part 1 of our JavaScript Functions Tutorial Series, designed for beginners, freshers, and advanced learnersβ¦
Today, let's understand another programming concept:
π₯ Sorting Algorithmsππ»
Sorting is one of the most frequently asked topics in coding interviews.
π What is Sorting?
Sorting means arranging data in a specific order:
- Ascending β 1, 2, 3, 4
- Descending β 4, 3, 2, 1
Used in:
- Searching
- Data analysis
- Databases
- Optimization problems
π§ Important Sorting Algorithms
1οΈβ£ Bubble Sort
- Concept: Repeatedly compares adjacent elements and swaps them if they are in the wrong order.
- Example: [5, 3, 2] β compare 5 & 3 β swap β [3, 5, 2]
- Key Point: Simple but inefficient
- Time Complexity: O(nΒ²)
2οΈβ£ Selection Sort
- Concept: Find the smallest element and place it at the beginning.
- Example: [4, 2, 1] β pick 1 β place at start β [1, 2, 4]
- Key Point: Fewer swaps than bubble sort
- Time Complexity: O(nΒ²)
3οΈβ£ Insertion Sort
- Concept: Builds sorted list one element at a time.
- Example: [3, 1, 2] Insert 1 in correct position β [1, 3, 2]
- Key Point: Efficient for small datasets
- Time Complexity: O(nΒ²), but good for nearly sorted data
4οΈβ£ Merge Sort
- Concept: Divide array into halves, sort them, then merge.
- Example: [4,2,1,3] β split β [4,2] & [1,3] β sort β merge
- Key Point: Very efficient
- Time Complexity: O(n log n)
- Uses extra memory
5οΈβ£ Quick Sort
- Concept: Pick a pivot and place smaller elements on left, larger on right.
- Example: [4,2,5,1] β pivot = 4 β [2,1] 4 [5]
- Key Point: Very fast in practice
- Average: O(n log n)
- Worst: O(nΒ²)
π― When to Use What
- Small dataset β Insertion Sort
- Large dataset β Merge / Quick Sort
- Nearly sorted β Insertion Sort
- Memory constraint β Quick Sort
β οΈ Common Interview Questions
- Which sorting is fastest? π Quick Sort (average case)
- Which is stable? π Merge Sort
- Which uses divide & conquer? π Merge & Quick Sort
β Real Insight
Interviewers test:
- Understanding of logic
- Time complexity
- When to use which algorithm
Double Tap β€οΈ For More
π₯ Sorting Algorithmsππ»
Sorting is one of the most frequently asked topics in coding interviews.
π What is Sorting?
Sorting means arranging data in a specific order:
- Ascending β 1, 2, 3, 4
- Descending β 4, 3, 2, 1
Used in:
- Searching
- Data analysis
- Databases
- Optimization problems
π§ Important Sorting Algorithms
1οΈβ£ Bubble Sort
- Concept: Repeatedly compares adjacent elements and swaps them if they are in the wrong order.
- Example: [5, 3, 2] β compare 5 & 3 β swap β [3, 5, 2]
- Key Point: Simple but inefficient
- Time Complexity: O(nΒ²)
2οΈβ£ Selection Sort
- Concept: Find the smallest element and place it at the beginning.
- Example: [4, 2, 1] β pick 1 β place at start β [1, 2, 4]
- Key Point: Fewer swaps than bubble sort
- Time Complexity: O(nΒ²)
3οΈβ£ Insertion Sort
- Concept: Builds sorted list one element at a time.
- Example: [3, 1, 2] Insert 1 in correct position β [1, 3, 2]
- Key Point: Efficient for small datasets
- Time Complexity: O(nΒ²), but good for nearly sorted data
4οΈβ£ Merge Sort
- Concept: Divide array into halves, sort them, then merge.
- Example: [4,2,1,3] β split β [4,2] & [1,3] β sort β merge
- Key Point: Very efficient
- Time Complexity: O(n log n)
- Uses extra memory
5οΈβ£ Quick Sort
- Concept: Pick a pivot and place smaller elements on left, larger on right.
- Example: [4,2,5,1] β pivot = 4 β [2,1] 4 [5]
- Key Point: Very fast in practice
- Average: O(n log n)
- Worst: O(nΒ²)
π― When to Use What
- Small dataset β Insertion Sort
- Large dataset β Merge / Quick Sort
- Nearly sorted β Insertion Sort
- Memory constraint β Quick Sort
β οΈ Common Interview Questions
- Which sorting is fastest? π Quick Sort (average case)
- Which is stable? π Merge Sort
- Which uses divide & conquer? π Merge & Quick Sort
β Real Insight
Interviewers test:
- Understanding of logic
- Time complexity
- When to use which algorithm
Double Tap β€οΈ For More
β
Useful Platform to Practice SQL Programming π§ π₯οΈ
Learning SQL is just the first step β practice is what builds real skill. Here are the best platforms for hands-on SQL:
1οΈβ£ LeetCode β For Interview-Oriented SQL Practice
β’ Focus: Real interview-style problems
β’ Levels: Easy to Hard
β’ Schema + Sample Data Provided
β’ Great for: Data Analyst, Data Engineer, FAANG roles
β Tip: Start with Easy β filter by βDatabaseβ tag
β Popular Section: Database β Top 50 SQL Questions
Example Problem: βFind duplicate emails in a user tableβ β Practice filtering, GROUP BY, HAVING
2οΈβ£ HackerRank β Structured & Beginner-Friendly
β’ Focus: Step-by-step SQL track
β’ Has certification tests (SQL Basic, Intermediate)
β’ Problem sets by topic: SELECT, JOINs, Aggregations, etc.
β Tip: Follow the full SQL track
β Bonus: Company-specific challenges
Try: βRevising Aggregations β The Count Functionβ β Build confidence with small wins
3οΈβ£ Mode Analytics β Real-World SQL in Business Context
β’ Focus: Business intelligence + SQL
β’ Uses real-world datasets (e.g., e-commerce, finance)
β’ Has an in-browser SQL editor with live data
β Best for: Practicing dashboard-level queries
β Tip: Try the SQL case studies & tutorials
4οΈβ£ StrataScratch β Interview Questions from Real Companies
β’ 500+ problems from companies like Uber, Netflix, Google
β’ Split by company, difficulty, and topic
β Best for: Intermediate to advanced level
β Tip: Try βHardβ questions after doing 30β50 easy/medium
5οΈβ£ DataLemur β Short, Practical SQL Problems
β’ Crisp and to the point
β’ Good UI, fast learning
β’ Real interview-style logic
β Use when: You want fast, smart SQL drills
π How to Practice Effectively:
β’ Spend 20β30 mins/day
β’ Focus on JOINs, GROUP BY, HAVING, Subqueries
β’ Analyze problem β write β debug β re-write
β’ After solving, explain your logic out loud
π§ͺ Practice Task:
Try solving 5 SQL questions from LeetCode or HackerRank this week. Start with SELECT, WHERE, and GROUP BY.
π¬ Tap β€οΈ for more!
Learning SQL is just the first step β practice is what builds real skill. Here are the best platforms for hands-on SQL:
1οΈβ£ LeetCode β For Interview-Oriented SQL Practice
β’ Focus: Real interview-style problems
β’ Levels: Easy to Hard
β’ Schema + Sample Data Provided
β’ Great for: Data Analyst, Data Engineer, FAANG roles
β Tip: Start with Easy β filter by βDatabaseβ tag
β Popular Section: Database β Top 50 SQL Questions
Example Problem: βFind duplicate emails in a user tableβ β Practice filtering, GROUP BY, HAVING
2οΈβ£ HackerRank β Structured & Beginner-Friendly
β’ Focus: Step-by-step SQL track
β’ Has certification tests (SQL Basic, Intermediate)
β’ Problem sets by topic: SELECT, JOINs, Aggregations, etc.
β Tip: Follow the full SQL track
β Bonus: Company-specific challenges
Try: βRevising Aggregations β The Count Functionβ β Build confidence with small wins
3οΈβ£ Mode Analytics β Real-World SQL in Business Context
β’ Focus: Business intelligence + SQL
β’ Uses real-world datasets (e.g., e-commerce, finance)
β’ Has an in-browser SQL editor with live data
β Best for: Practicing dashboard-level queries
β Tip: Try the SQL case studies & tutorials
4οΈβ£ StrataScratch β Interview Questions from Real Companies
β’ 500+ problems from companies like Uber, Netflix, Google
β’ Split by company, difficulty, and topic
β Best for: Intermediate to advanced level
β Tip: Try βHardβ questions after doing 30β50 easy/medium
5οΈβ£ DataLemur β Short, Practical SQL Problems
β’ Crisp and to the point
β’ Good UI, fast learning
β’ Real interview-style logic
β Use when: You want fast, smart SQL drills
π How to Practice Effectively:
β’ Spend 20β30 mins/day
β’ Focus on JOINs, GROUP BY, HAVING, Subqueries
β’ Analyze problem β write β debug β re-write
β’ After solving, explain your logic out loud
π§ͺ Practice Task:
Try solving 5 SQL questions from LeetCode or HackerRank this week. Start with SELECT, WHERE, and GROUP BY.
π¬ Tap β€οΈ for more!
Now, let's move to the next topic in the Web Development Roadmap:
π HTTP vs HTTPS (Internet Basics π)
π§ What is HTTP?
π HTTP = HyperText Transfer Protocol
- Used to transfer data between browser β server
- Not secure β
- Data is sent in plain text
π‘ Example:
If you enter password β it can be intercepted π¬
π What is HTTPS?
π HTTPS = Secure version of HTTP
- Uses SSL/TLS encryption
- Data is encrypted π
- Safe for:
- Payments π³
- Logins π
π‘ Example:
Even if someone intercepts β they canβt read data
βοΈ Key Difference (Must Remember)
Security
- HTTP: β Not secure
- HTTPS: β Secure
Encryption
- HTTP: β No
- HTTPS: β Yes
URL
- HTTP: http://
- HTTPS: https://
Use case
- HTTP: Basic sites
- HTTPS: Login, banking
π How to Identify HTTPS?
π Look at browser address bar:
- π Lock icon = Secure
- No lock = Not safe
β‘ Real-Life Example
π Think like sending a message:
- HTTP = Normal message (anyone can read)
- HTTPS = Locked message (only receiver can read)
π What is SSL/TLS?
- Itβs a security layer
- Encrypts data between browser & server
π Thatβs why HTTPS is safe
π― Mini Task
1. Open any website
2. Check URL:
- Starts with https?
- Lock icon visible?
π Try both secure & non-secure sites
π‘ HTTPS ensures secure communication using encryption (SSL/TLS)
Double Tap β€οΈ For More
π HTTP vs HTTPS (Internet Basics π)
π§ What is HTTP?
π HTTP = HyperText Transfer Protocol
- Used to transfer data between browser β server
- Not secure β
- Data is sent in plain text
π‘ Example:
If you enter password β it can be intercepted π¬
π What is HTTPS?
π HTTPS = Secure version of HTTP
- Uses SSL/TLS encryption
- Data is encrypted π
- Safe for:
- Payments π³
- Logins π
π‘ Example:
Even if someone intercepts β they canβt read data
βοΈ Key Difference (Must Remember)
Security
- HTTP: β Not secure
- HTTPS: β Secure
Encryption
- HTTP: β No
- HTTPS: β Yes
URL
- HTTP: http://
- HTTPS: https://
Use case
- HTTP: Basic sites
- HTTPS: Login, banking
π How to Identify HTTPS?
π Look at browser address bar:
- π Lock icon = Secure
- No lock = Not safe
β‘ Real-Life Example
π Think like sending a message:
- HTTP = Normal message (anyone can read)
- HTTPS = Locked message (only receiver can read)
π What is SSL/TLS?
- Itβs a security layer
- Encrypts data between browser & server
π Thatβs why HTTPS is safe
π― Mini Task
1. Open any website
2. Check URL:
- Starts with https?
- Lock icon visible?
π Try both secure & non-secure sites
π‘ HTTPS ensures secure communication using encryption (SSL/TLS)
Double Tap β€οΈ For More
JavaScript Interview Practice Questions (Logic Building Test)
Section A β If-Else & Basic Logic
Q1.
Find the largest number in the given array without using Math.max().
Q2.
Count the even and odd numbers present in an array.
Q3.
Check whether a given string is a Palindrome or not.
Q4.
Find the second largest number in an array without sorting it.
Q5.
Calculate the factorial of a given number.
Section B β Loops (for, while, do...while)
Q6.
Print all numbers from 1 to 100 using a for loop.
Q7.
Print all even numbers between 1 and 100.
Q8.
Print all odd numbers between 1 and 100.
Q9.
Print the multiplication table of a given number.
Q10.
Print the Fibonacci Series up to n terms.
Q11.
Print all prime numbers between 1 and 100.
Q12.
Reverse a given string using a loop.
Q13.
Reverse an array without using the .reverse() method.
Q14.
Print numbers from 10 to 1 using a while loop.
Q15.
Write a program using a do...while loop that executes at least one time even if the condition is false.
Section C β Switch Case
Q16.
Display the name of the day based on a number (1β7) using switch.
Q17.
Create a simple calculator using switch (+, -, *, /).
Q18.
Display the month name based on the month number (1β12).
Section D β Arrays
Q19.
Find the sum of all elements in an array.
Q20.
Find the smallest number in an array.
Q21.
Find the largest number in an array.
Q22.
Find all duplicate elements in an array.
Q23.
Remove duplicate elements from an array.
Q24.
Count how many times each element appears in an array.
Q25.
Find the missing number from an array containing numbers from 1 to n.
Q26.
Merge two arrays without duplicate values.
Q27.
Find the intersection of two arrays.
Q28.
Move all zero values to the end of an array.
Q29.
Rotate an array by one position.
Q30.
Sort an array in ascending order without using .sort().
Section A β If-Else & Basic Logic
Q1.
Find the largest number in the given array without using Math.max().
Q2.
Count the even and odd numbers present in an array.
Q3.
Check whether a given string is a Palindrome or not.
Q4.
Find the second largest number in an array without sorting it.
Q5.
Calculate the factorial of a given number.
Section B β Loops (for, while, do...while)
Q6.
Print all numbers from 1 to 100 using a for loop.
Q7.
Print all even numbers between 1 and 100.
Q8.
Print all odd numbers between 1 and 100.
Q9.
Print the multiplication table of a given number.
Q10.
Print the Fibonacci Series up to n terms.
Q11.
Print all prime numbers between 1 and 100.
Q12.
Reverse a given string using a loop.
Q13.
Reverse an array without using the .reverse() method.
Q14.
Print numbers from 10 to 1 using a while loop.
Q15.
Write a program using a do...while loop that executes at least one time even if the condition is false.
Section C β Switch Case
Q16.
Display the name of the day based on a number (1β7) using switch.
Q17.
Create a simple calculator using switch (+, -, *, /).
Q18.
Display the month name based on the month number (1β12).
Section D β Arrays
Q19.
Find the sum of all elements in an array.
Q20.
Find the smallest number in an array.
Q21.
Find the largest number in an array.
Q22.
Find all duplicate elements in an array.
Q23.
Remove duplicate elements from an array.
Q24.
Count how many times each element appears in an array.
Q25.
Find the missing number from an array containing numbers from 1 to n.
Q26.
Merge two arrays without duplicate values.
Q27.
Find the intersection of two arrays.
Q28.
Move all zero values to the end of an array.
Q29.
Rotate an array by one position.
Q30.
Sort an array in ascending order without using .sort().
Section E β Array Methods
Q31.
Use the map() method to create a new array containing the square of each number.
Q32.
Use the filter() method to extract only even numbers from an array.
Q33.
Use the reduce() method to calculate the sum of all array elements.
Q34.
Check whether a particular value exists in an array using array methods.
Q35.
Convert an array into a comma-separated string.
Section F β Strings
Q36.
Count the number of vowels in a string.
Q37.
Count the frequency of each character in a string.
Q38.
Find the longest word in a sentence.
Q39.
Check whether two strings are Anagrams.
Q40.
Reverse every word in a sentence.
Section G β Objects
Q41.
Print all keys and values of an object using for...in.
Q42.
Count the total number of properties in an object.
Q43.
Merge two objects into one object.
Q44.
Check whether a given property exists in an object.
Q45.
Convert an object into an array of keys.
Q46.
Convert an object into an array of values.
Q47.
Find the property with the highest value in an object.
Section H β Mixed Interview Logic
Q48.
Count the number of positive, negative, and zero values in an array.
Q49.
Find the maximum occurring element in an array.
Q50.
Write a program to display the following pattern:
*
**
***
****
*
Q51.
Wr
*
****
***
**
*
Q52.
W
*
***
*
***
1
12
123
1234
12345
Q54.
Wr
5
54
543
5432
54321
Name : Rah
Q31.
Use the map() method to create a new array containing the square of each number.
Q32.
Use the filter() method to extract only even numbers from an array.
Q33.
Use the reduce() method to calculate the sum of all array elements.
Q34.
Check whether a particular value exists in an array using array methods.
Q35.
Convert an array into a comma-separated string.
Section F β Strings
Q36.
Count the number of vowels in a string.
Q37.
Count the frequency of each character in a string.
Q38.
Find the longest word in a sentence.
Q39.
Check whether two strings are Anagrams.
Q40.
Reverse every word in a sentence.
Section G β Objects
Q41.
Print all keys and values of an object using for...in.
Q42.
Count the total number of properties in an object.
Q43.
Merge two objects into one object.
Q44.
Check whether a given property exists in an object.
Q45.
Convert an object into an array of keys.
Q46.
Convert an object into an array of values.
Q47.
Find the property with the highest value in an object.
Section H β Mixed Interview Logic
Q48.
Count the number of positive, negative, and zero values in an array.
Q49.
Find the maximum occurring element in an array.
Q50.
Write a program to display the following pattern:
*
**
***
****
*
Q51.
Wr
ite a program to display the following pattern:*
****
***
**
*
Q52.
W
rite a program to display the following pattern:*
***
*
***
*********
Q53.
Write a program to display the following pattern:1
12
123
1234
12345
Q54.
Wr
ite a program to display the following pattern:5
54
543
5432
54321
Q55.
Create a student object and display all student details in the following format:Name : Rah
ul
Age : 22
Course : MERN Stack
City : Indore
Ye 55 questions beginner se intermediate aur interview-oriented level ke hain. Inme if-else, switch, for, while, do...while, for...of, for...in, arrays, array methods, strings, objects aur logic building sab cover ho jata hai.https://youtu.be/vCyA5RSvi2I?si=maEYG2fTbYfz3dzf
is video ke comment section me jo mene test diya eh 50 question ka sections wise uski answersheet me ncihe de rahi hu .
JavaScript Test β Answer Sheet
Section A (Output Based)
Q1
Output:
Explanation: ++a pehle increment karta hai (11), a++ current value (11) use karke baad me increment karta hai. Final a = 12, b = 11 + 11 = 22.
Q2
Output:
Explanation: x++ returns 20, then x becomes 21. ++x makes it 22. Result = 20 + 22 = 42.
Q3
Output:
Explanation: 10 + "5" becomes "105" (string concatenation), then "105" - 2 = 103.
Q4
Output:
Explanation: typeof null returns "object" due to a historical JavaScript bug.
Q5
Output:
Explanation: Arrays are special types of objects, so typeof [] returns "object".
Q6
Output:
Explanation: trim() removes spaces and toUpperCase() converts all characters to uppercase.
Q7
Output:
Explanation: slice(0,9) returns characters from index 0 to 8.
Q8
Output:
Explanation: substring(4,10) returns characters from index 4 to 9.
Q9
Output:
Explanation: repeat(2) repeats the string twice.
Q10
Output:
Explanation: split(",") converts the string into an array using comma as the separator.
Q11
Output:
Explanation: push(40) adds 40; pop() immediately removes the last element.
Q12
Output:
Explanation: slice(1,3) returns elements from index 1 up to (but not including) index 3.
Q13
Output:
Explanation: splice(1,1,10) removes one element at index 1 and inserts 10.
Q14
Output:
Explanation: includes(20) checks whether 20 exists in the array.
Q15
Output:
Explanation: Every element is even, so every() returns true.
Q16
Output:
Explanation: 3 is greater than 2, so some() returns true.
Q17
Output:
Explanation: Object.keys() returns an array of all object keys.
Q18
Output:
Explanation: delete obj.name removes the name property, leaving an empty object.
Q19
Output:
Explanation: Object.freeze() prevents modification of existing properties, so a remains 10.
Q20
Output:
Explanation: 5 > 10 is false, so the ternary operator returns "No".
β Final Answer Key (Quick Checking)
SECTION : A
Q.No Answer
1) 12 22
2) 42
3) 103
4) "object"
5) "object"
6) JAVASCRIPT
7) Knowledge
8) Script
9) HelloHello
10) ["apple","banana","mango"]
11) [10,20,30]
12) [2,3]
13) [1,10,3]
14) true
15) true
16) true
17) ["name","city"]
18) {}
19) 10
20) No
is video ke comment section me jo mene test diya eh 50 question ka sections wise uski answersheet me ncihe de rahi hu .
JavaScript Test β Answer Sheet
Section A (Output Based)
Q1
Output:
12 22Explanation: ++a pehle increment karta hai (11), a++ current value (11) use karke baad me increment karta hai. Final a = 12, b = 11 + 11 = 22.
Q2
Output:
42Explanation: x++ returns 20, then x becomes 21. ++x makes it 22. Result = 20 + 22 = 42.
Q3
Output:
103Explanation: 10 + "5" becomes "105" (string concatenation), then "105" - 2 = 103.
Q4
Output:
objectExplanation: typeof null returns "object" due to a historical JavaScript bug.
Q5
Output:
objectExplanation: Arrays are special types of objects, so typeof [] returns "object".
Q6
Output:
JAVASCRIPTExplanation: trim() removes spaces and toUpperCase() converts all characters to uppercase.
Q7
Output:
KnowledgeExplanation: slice(0,9) returns characters from index 0 to 8.
Q8
Output:
ScriptExplanation: substring(4,10) returns characters from index 4 to 9.
Q9
Output:
HelloHelloExplanation: repeat(2) repeats the string twice.
Q10
Output:
["apple", "banana", "mango"]Explanation: split(",") converts the string into an array using comma as the separator.
Q11
Output:
[10, 20, 30]Explanation: push(40) adds 40; pop() immediately removes the last element.
Q12
Output:
[2, 3]Explanation: slice(1,3) returns elements from index 1 up to (but not including) index 3.
Q13
Output:
[1, 10, 3]Explanation: splice(1,1,10) removes one element at index 1 and inserts 10.
Q14
Output:
trueExplanation: includes(20) checks whether 20 exists in the array.
Q15
Output:
trueExplanation: Every element is even, so every() returns true.
Q16
Output:
trueExplanation: 3 is greater than 2, so some() returns true.
Q17
Output:
["name", "city"]Explanation: Object.keys() returns an array of all object keys.
Q18
Output:
{}Explanation: delete obj.name removes the name property, leaving an empty object.
Q19
Output:
10Explanation: Object.freeze() prevents modification of existing properties, so a remains 10.
Q20
Output:
NoExplanation: 5 > 10 is false, so the ternary operator returns "No".
β Final Answer Key (Quick Checking)
SECTION : A
Q.No Answer
1) 12 22
2) 42
3) 103
4) "object"
5) "object"
6) JAVASCRIPT
7) Knowledge
8) Script
9) HelloHello
10) ["apple","banana","mango"]
11) [10,20,30]
12) [2,3]
13) [1,10,3]
14) true
15) true
16) true
17) ["name","city"]
18) {}
19) 10
20) No
YouTube
JavaScript Core Fundamentals in 5 Hours! | Datatypes, Arrays, Objects, Strings & Operators (Part 1)
Welcome to Part 1 of the Ultimate JavaScript Masterclass! π
In this massive 5-hour comprehensive tutorial, we are diving deep into the absolute core fundamentals of JavaScript. Whether you are a beginner or brushing up on your concepts, this video coversβ¦
In this massive 5-hour comprehensive tutorial, we are diving deep into the absolute core fundamentals of JavaScript. Whether you are a beginner or brushing up on your concepts, this video coversβ¦
JavaScript Test β Answer Sheet
---->>> Section B β Theory Questions (21β35)
Q21. Differentiate between var, let and const.
Answer:
var , let, const
Function scoped , Block scoped , Block scoped
Can be redeclared , Cannot be redeclared, Cannot be redeclared
Can be reassigned , Can be reassigned , Cannot be reassigned
Hoisted and initialized with undefined, Hoisted but in Temporal Dead Zone , Hoisted but in Temporal Dead Zone
Explanation:
var is the old way of declaring variables. let is used when the value may change, and const is used for values that should not be reassigned.
Q22. What is the difference between == and ===?
Answer:
== (Loose Equality) compares only values and performs type conversion if needed.
=== (Strict Equality) compares both value and data type without type conversion.
Example:
Explanation:
Always prefer === because it gives more accurate comparisons.
Q23. Explain pre-increment and post-increment with an example.
Answer:
Pre-increment (++a) increases the value before it is used.
Post-increment (a++) uses the current value first and then increases it.
Example:
Explanation:
The main difference is when the increment happens.
Q24. What is the purpose of the typeof operator?
Answer:
The typeof operator is used to determine the data type of a variable or value.
Example:
Explanation:
It helps identify the type of data stored in a variable.
Q25. What is the difference between slice() and substring()?
Answer:
slice(), substring()
Supports negative indexes , Does not support negative indexes
Does not swap indexes, Swaps indexes if start > end
Explanation:
Both return a part of a string, but slice() is more flexible because it supports negative indexing.
Q26. Differentiate between splice() and slice().
Answer:
splice(), slice()
Changes the original array, Does not change the original array
Used to add/remove elements, Used to copy a portion of an array
Returns removed elements, Returns a new array
Explanation:
splice() modifies the original array, whereas slice() creates a new array.
Q27. What is the difference between push() and unshift()?
Answer:
push() adds element(s) at the end of an array.
unshift() adds element(s) at the beginning of an array.
Example:
Explanation:
Both methods add elements, but at different positions.
Q28. Differentiate between pop() and shift().
Answer:
pop() removes the last element from an array.
shift() removes the first element from an array.
Explanation:
Both remove one element, but from opposite ends of the array.
Q29. Explain the difference between map() and forEach().
Answer:
map() , forEach()
Returns a new array, Does not return a new array (returns undefined)
Used for transformation, Used for iteration
Original array remains unchanged, Original array remains unchanged unless modified manually
Explanation:
Use map() when you need a transformed array. Use forEach() when you only want to perform an action on each element.
Q30. Differentiate between filter() and find().
Answer:
filter(), find()
Returns all matching elements, Returns only the first matching element
Returns an array, Returns a single value or undefined
Explanation:
Use filter() for multiple results and find() when only the first match is required.
Q31. What is the use of the reduce() method?
Answer:
reduce() is used to reduce an array into a single value by applying a callback function to each element.
Example:
Explanation:
It is commonly used for calculating sums, products, averages, and other aggregated values.
---->>> Section B β Theory Questions (21β35)
Q21. Differentiate between var, let and const.
Answer:
var , let, const
Function scoped , Block scoped , Block scoped
Can be redeclared , Cannot be redeclared, Cannot be redeclared
Can be reassigned , Can be reassigned , Cannot be reassigned
Hoisted and initialized with undefined, Hoisted but in Temporal Dead Zone , Hoisted but in Temporal Dead Zone
Explanation:
var is the old way of declaring variables. let is used when the value may change, and const is used for values that should not be reassigned.
Q22. What is the difference between == and ===?
Answer:
== (Loose Equality) compares only values and performs type conversion if needed.
=== (Strict Equality) compares both value and data type without type conversion.
Example:
5 == "5" // true
5 === "5" // falseExplanation:
Always prefer === because it gives more accurate comparisons.
Q23. Explain pre-increment and post-increment with an example.
Answer:
Pre-increment (++a) increases the value before it is used.
Post-increment (a++) uses the current value first and then increases it.
Example:
let a = 5;
console.log(++a); // 6
let b = 5;
console.log(b++); // 5
console.log(b); // 6Explanation:
The main difference is when the increment happens.
Q24. What is the purpose of the typeof operator?
Answer:
The typeof operator is used to determine the data type of a variable or value.
Example:
typeof 10 // "number"
typeof "Hello" // "string"
typeof true // "boolean"
typeof undefined // "undefined"
typeof [] // "object"Explanation:
It helps identify the type of data stored in a variable.
Q25. What is the difference between slice() and substring()?
Answer:
slice(), substring()
Supports negative indexes , Does not support negative indexes
Does not swap indexes, Swaps indexes if start > end
Explanation:
Both return a part of a string, but slice() is more flexible because it supports negative indexing.
Q26. Differentiate between splice() and slice().
Answer:
splice(), slice()
Changes the original array, Does not change the original array
Used to add/remove elements, Used to copy a portion of an array
Returns removed elements, Returns a new array
Explanation:
splice() modifies the original array, whereas slice() creates a new array.
Q27. What is the difference between push() and unshift()?
Answer:
push() adds element(s) at the end of an array.
unshift() adds element(s) at the beginning of an array.
Example:
arr.push(5);
arr.unshift(1);Explanation:
Both methods add elements, but at different positions.
Q28. Differentiate between pop() and shift().
Answer:
pop() removes the last element from an array.
shift() removes the first element from an array.
Explanation:
Both remove one element, but from opposite ends of the array.
Q29. Explain the difference between map() and forEach().
Answer:
map() , forEach()
Returns a new array, Does not return a new array (returns undefined)
Used for transformation, Used for iteration
Original array remains unchanged, Original array remains unchanged unless modified manually
Explanation:
Use map() when you need a transformed array. Use forEach() when you only want to perform an action on each element.
Q30. Differentiate between filter() and find().
Answer:
filter(), find()
Returns all matching elements, Returns only the first matching element
Returns an array, Returns a single value or undefined
Explanation:
Use filter() for multiple results and find() when only the first match is required.
Q31. What is the use of the reduce() method?
Answer:
reduce() is used to reduce an array into a single value by applying a callback function to each element.
Example:
let arr = [1,2,3];
let sum = arr.reduce((acc, curr) => acc + curr, 0);Explanation:
It is commonly used for calculating sums, products, averages, and other aggregated values.
Q32. Differentiate between Object.freeze() and Object.seal().
Answer:
Object.freeze() Object.seal()
Cannot add, delete, or modify properties Cannot add or delete properties, but existing properties can still be
Explanation:
freeze() makes an object completely immutable, whereas seal() partially restricts changes.
Q33. Explain the purpose of Object.keys(), Object.values(), and Object.entries().
Answer:
Object.keys() returns an array of all property names (keys).
Object.values() returns an array of all property values.
Object.entries() returns an array of key-value pairs.
Example:
Object.keys(obj) β ["name", "age"]
Object.values(obj) β ["Payal", 22]
Object.entries(obj) β [["name","Payal"],["age",22]]
Explanation:
These methods are commonly used to access and iterate over object data.
Q34. What is Array Destructuring? Explain with an example.
Answer:
Array Destructuring is a feature that allows values from an array to be assigned directly to variables.
Example:
Explanation:
Instead of accessing elements using indexes, destructuring provides a cleaner and shorter syntax.
Q35. What is the Spread Operator? Explain with an example.
Answer:
The Spread Operator (...) is used to expand elements of an array or properties of an object.
Example:
Explanation:
It is commonly used for copying arrays or objects, merging arrays or objects, and passing multiple values to functions.
β Quick Checking Key
Q.No) Expected Answer
21) Difference between var, let, const
22) == vs ===
23) Pre-increment vs Post-increment
24) Purpose of typeof
25) slice() vs substring()
26) splice() vs slice()
27) push() vs unshift()
28) pop() vs shift()
29) map() vs forEach()
30) filter() vs find()
31) Use of reduce()
32) Object.freeze() vs Object.seal()
33) Object.keys(), Object.values(), Object.entries()
34) Array Destructuring
35) Spread Operator (...)
Note: Q32 ka answer ek important correction ke saath diya gaya hai: Object.seal() existing properties ko modify karne deta hai sirf tab jab woh properties writable hon. Ye JavaScript ka actual behavior hai aur interview point of view se bhi accurate answer hai.
Answer:
Object.freeze() Object.seal()
Cannot add, delete, or modify properties Cannot add or delete properties, but existing properties can still be
Explanation:
freeze() makes an object completely immutable, whereas seal() partially restricts changes.
Q33. Explain the purpose of Object.keys(), Object.values(), and Object.entries().
Answer:
Object.keys() returns an array of all property names (keys).
Object.values() returns an array of all property values.
Object.entries() returns an array of key-value pairs.
Example:
const obj = {
name: "Payal",
age: 22
};Object.keys(obj) β ["name", "age"]
Object.values(obj) β ["Payal", 22]
Object.entries(obj) β [["name","Payal"],["age",22]]
Explanation:
These methods are commonly used to access and iterate over object data.
Q34. What is Array Destructuring? Explain with an example.
Answer:
Array Destructuring is a feature that allows values from an array to be assigned directly to variables.
Example:
let arr = [10,20,30];
let [a,b,c] = arr;Explanation:
Instead of accessing elements using indexes, destructuring provides a cleaner and shorter syntax.
Q35. What is the Spread Operator? Explain with an example.
Answer:
The Spread Operator (...) is used to expand elements of an array or properties of an object.
Example:
let arr1 = [1,2,3];
let arr2 = [...arr1,4,5];Explanation:
It is commonly used for copying arrays or objects, merging arrays or objects, and passing multiple values to functions.
β Quick Checking Key
Q.No) Expected Answer
21) Difference between var, let, const
22) == vs ===
23) Pre-increment vs Post-increment
24) Purpose of typeof
25) slice() vs substring()
26) splice() vs slice()
27) push() vs unshift()
28) pop() vs shift()
29) map() vs forEach()
30) filter() vs find()
31) Use of reduce()
32) Object.freeze() vs Object.seal()
33) Object.keys(), Object.values(), Object.entries()
34) Array Destructuring
35) Spread Operator (...)
Note: Q32 ka answer ek important correction ke saath diya gaya hai: Object.seal() existing properties ko modify karne deta hai sirf tab jab woh properties writable hon. Ye JavaScript ka actual behavior hai aur interview point of view se bhi accurate answer hai.
JavaScript Test β Answer Sheet
---->>> Section C β Interview Based Questions (36β45)
Q36. What is the difference between Primitive and Reference Data Types?
Answer:
Primitive Data Types Reference Data Types
Store the actual value Store the memory reference (address)
Copied by value Copied by reference
Immutable Mutable (objects and arrays can be modified)
Primitive Types: Number, String, Boolean, Undefined, Null, BigInt, Symbol
Reference Types: Object, Array, Function
Explanation:
Primitive variables store the actual value, while reference variables store the address of the object in memory.
Q37. What is the difference between indexOf() and includes()?
Answer:
indexOf() includes()
Returns the index of the element Returns true or false
Returns -1 if not found Returns false if not found
Example:
Explanation:
Use indexOf() when you need the position of an element and includes() when you only need to check its existence.
Q38. Why does typeof null return "object"?
Answer:
typeof null returns "object" because of a historical bug in JavaScript. This behavior has been preserved for backward compatibility and cannot be changed without breaking existing code.
Explanation:
Although null represents the intentional absence of a value, JavaScript still reports its type as "object".
Q39. When should we use const instead of let?
Answer:
Use const when the variable should not be reassigned after its initial declaration.
Use let when the variable's value needs to change later in the program.
Explanation:
Using const helps prevent accidental reassignment and makes the code more predictable and easier to maintain.
Q40. Explain the difference between Object.assign() and structuredClone().
Answer:
Object.assign() structuredClone()
Creates a shallow copy Creates a deep copy
Nested objects are shared Nested objects are copied independently
Suitable for simple objects Suitable for complex nested objects
Explanation:
Use Object.assign() for shallow cloning and structuredClone() when a true deep copy of an object is required.
Q41. What is the difference between hasOwnProperty() and the in operator?
Answer:
hasOwnProperty() in operator
Checks only the object's own properties Checks both own and inherited properties
Does not check the prototype chain Checks the prototype chain as well
Example:
Explanation:
Use hasOwnProperty() to verify that a property belongs directly to the object. Use the in operator to check whether a property exists anywhere in the object's prototype chain.
Q42. What is the difference between sort() and reverse()?
Answer:
sort() reverse()
Arranges elements in a specified/default order Reverses the current order of elements
Changes the original array Changes the original array
Explanation:
sort() is used for sorting values, whereas reverse() simply reverses the existing order of elements.
Q43. Explain instanceof with an example.
Answer:
The instanceof operator checks whether an object is an instance of a particular constructor or class.
Example:
Explanation:
It returns true if the object's prototype chain contains the constructor's prototype; otherwise, it returns false.
Q44. What is the difference between Object.create() and object literals ({})?
Answer:
Object.create() Object Literal ({})
Creates a new object with a specified prototype Creates a normal object with Object.prototype as its prototype
Allows custom prototype inheritance Uses the default prototype
Explanation:
Object.create() is useful when you want to control an object's prototype, while {} is the standard and most common way to create objects.
---->>> Section C β Interview Based Questions (36β45)
Q36. What is the difference between Primitive and Reference Data Types?
Answer:
Primitive Data Types Reference Data Types
Store the actual value Store the memory reference (address)
Copied by value Copied by reference
Immutable Mutable (objects and arrays can be modified)
Primitive Types: Number, String, Boolean, Undefined, Null, BigInt, Symbol
Reference Types: Object, Array, Function
Explanation:
Primitive variables store the actual value, while reference variables store the address of the object in memory.
Q37. What is the difference between indexOf() and includes()?
Answer:
indexOf() includes()
Returns the index of the element Returns true or false
Returns -1 if not found Returns false if not found
Example:
let arr = [10,20,30];
arr.indexOf(20); // 1
arr.includes(20); // trueExplanation:
Use indexOf() when you need the position of an element and includes() when you only need to check its existence.
Q38. Why does typeof null return "object"?
Answer:
typeof null returns "object" because of a historical bug in JavaScript. This behavior has been preserved for backward compatibility and cannot be changed without breaking existing code.
Explanation:
Although null represents the intentional absence of a value, JavaScript still reports its type as "object".
Q39. When should we use const instead of let?
Answer:
Use const when the variable should not be reassigned after its initial declaration.
Use let when the variable's value needs to change later in the program.
Explanation:
Using const helps prevent accidental reassignment and makes the code more predictable and easier to maintain.
Q40. Explain the difference between Object.assign() and structuredClone().
Answer:
Object.assign() structuredClone()
Creates a shallow copy Creates a deep copy
Nested objects are shared Nested objects are copied independently
Suitable for simple objects Suitable for complex nested objects
Explanation:
Use Object.assign() for shallow cloning and structuredClone() when a true deep copy of an object is required.
Q41. What is the difference between hasOwnProperty() and the in operator?
Answer:
hasOwnProperty() in operator
Checks only the object's own properties Checks both own and inherited properties
Does not check the prototype chain Checks the prototype chain as well
Example:
obj.hasOwnProperty("name");
"name" in obj;Explanation:
Use hasOwnProperty() to verify that a property belongs directly to the object. Use the in operator to check whether a property exists anywhere in the object's prototype chain.
Q42. What is the difference between sort() and reverse()?
Answer:
sort() reverse()
Arranges elements in a specified/default order Reverses the current order of elements
Changes the original array Changes the original array
Explanation:
sort() is used for sorting values, whereas reverse() simply reverses the existing order of elements.
Q43. Explain instanceof with an example.
Answer:
The instanceof operator checks whether an object is an instance of a particular constructor or class.
Example:
let arr = [1,2,3];
arr instanceof Array; // true
arr instanceof Object; // trueExplanation:
It returns true if the object's prototype chain contains the constructor's prototype; otherwise, it returns false.
Q44. What is the difference between Object.create() and object literals ({})?
Answer:
Object.create() Object Literal ({})
Creates a new object with a specified prototype Creates a normal object with Object.prototype as its prototype
Allows custom prototype inheritance Uses the default prototype
Explanation:
Object.create() is useful when you want to control an object's prototype, while {} is the standard and most common way to create objects.
Q45. What is the purpose of JSON.stringify() and JSON.parse()?
Answer:
JSON.stringify() converts a JavaScript object into a JSON string.
JSON.parse() converts a JSON string back into a JavaScript object.
Example:
let obj = {
name: "Payal"
};
let json =
JSON.stringify(obj);
let data = JSON.parse(json);Explanation:
These methods are commonly used for data storage, API communication, and converting objects into a transferable format.
β Quick Checking Key
Q.No Expected Answer
36 Primitive vs Reference Data Types
37 indexOf() vs includes()
38 Why typeof null is "object"
39 When to use const instead of let
40 Object.assign() vs structuredClone()
41 hasOwnProperty() vs in operator
42 sort() vs reverse()
43 instanceof operator
44 Object.create() vs {}
45 JSON.stringify() vs JSON.parse()
Accuracy Note: Is answer sheet me diye gaye concepts JavaScript ke standard behavior ke according hain. Q40 (shallow vs deep copy), Q41 (prototype chain), Q43 (instanceof), aur Q44 (prototype inheritance) interview me frequently puche jaate hain, isliye unke explanations bhi interview-standard level ke rakhe gaye hain.