Web Development - HTML, CSS & JavaScript
Learn to code and become a Web Developer with HTML, CSS, JavaScript , Reactjs, Wordpress, PHP, Mern & Nodejs knowledge Managed by: @love_data
Show more📈 Analytical overview of Telegram channel Web Development - HTML, CSS & JavaScript
Channel Web Development - HTML, CSS & JavaScript (@javascript_courses) in the English language segment is an active participant. Currently, the community unites 55 673 subscribers, ranking 2 378 in the Technologies & Applications category and 6 212 in the India region.
📊 Audience metrics and dynamics
Since its creation on невідомо, the project has demonstrated rapid growth, gathering an audience of 55 673 subscribers.
According to the latest data from 27 October, 2026, the channel demonstrates stable activity. Although there has been a change in the number of participants by -3 over the last 30 days and by -4 over the last 24 hours, overall reach remains high.
- Verification status: Not verified
- Engagement rate (ER): The average audience engagement rate is 3.74%. Within the first 24 hours after publication, content typically collects 1.17% reactions from the total number of subscribers.
- Post reach: On average, each post receives 2 080 views. Within the first day, a publication typically gains 652 views.
- Reactions and interaction: The audience actively supports content: the average number of reactions per post is 3.
- Thematic interests: Content is focused on key topics such as javascript, css, object, html, array.
📝 Description and content policy
The author describes the resource as a platform for expressing subjective opinions:
“Learn to code and become a Web Developer with HTML, CSS, JavaScript , Reactjs, Wordpress, PHP, Mern & Nodejs knowledge
Managed by: @love_data”
Thanks to the high frequency of updates (latest data received on 28 October, 2026), the channel maintains relevance and a high level of publication reach. Analytics show that the audience actively interacts with content, making it an important point of influence in the Technologies & Applications category.
function sumArray(arr) {
return arr.reduce((total, num) => total + num, 0);
}
console.log(sumArray([1, 2, 3, 4]));
Output:
10
Using Loop
function sumArray(arr) {
let sum = 0;
for (let num of arr) {
sum += num;
}
return sum;
}
92. Write a function to reverse a string.
Using split(), reverse(), join()
function reverseString(str) {
return str.split("").reverse().join("");
}
console.log(reverseString("hello"));
Output:
olleh
Using Loop
function reverseString(str) {
let reversed = "";
for (let i = str.length - 1; i >= 0; i--) {
reversed += str[i];
}
return reversed;
}
93. Write a function to find the largest number in an array.
Using Math.max()
function largestNumber(arr) {
return Math.max(...arr);
}
console.log(largestNumber([2, 8, 5, 1]));
Output:
8
Using Loop
function largestNumber(arr) {
let largest = arr[0];
for (let num of arr) {
if (num > largest) {
largest = num;
}
}
return largest;
}
94. Write a function to check if a string is a palindrome.
A palindrome reads same forward and backward.
Example:
function isPalindrome(str) {
const reversed = str.split("").reverse().join("");
return str === reversed;
}
console.log(isPalindrome("madam"));
Output:
true
Case-Insensitive Version
function isPalindrome(str) {
str = str.toLowerCase();
return str === str.split("").reverse().join("");
}
95. Write a function to remove duplicates from an array.
Using Set
function removeDuplicates(arr) {
return [...new Set(arr)];
}
console.log(removeDuplicates([1, 2, 2, 3, 4, 4]));
Output:
[1, 2, 3, 4]
Using filter()
function removeDuplicates(arr) {
return arr.filter((item, index) =>
arr.indexOf(item) === index
);
}
96. Write a function to implement debounce.
Debouncing delays execution until the user stops triggering events.
Example:
function debounce(fn, delay) {
let timer;
return function(...args) {
clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(this, args);
}, delay);
};
}
Usage:
const search = debounce(() => {
console.log("Searching...");
}, 500);
Common Uses:
• Search bars
• Resize events
• Auto-save
97. Write a function to implement throttle.
Throttling limits execution frequency.
Example:
function throttle(fn, delay) {
let lastCall = 0;
return function(...args) {
const now = Date.now();
if (now - lastCall >= delay) {
lastCall = now;
fn.apply(this, args);
}
};
}
Usage:
const scrollHandler = throttle(() => {
console.log("Scrolling...");
}, 1000);
Common Uses:
• Scroll events
• Mouse movement
• Window resizing
98. Write a function to flatten a nested array.
Using flat()
function flattenArray(arr) {
return arr.flat(Infinity);
}
console.log(flattenArray([1, [2, [3, 4]]]));
Output:
[1, 2, 3, 4]
Recursive Solution
function flattenArray(arr) {
let result = [];
for (let item of arr) {
if (Array.isArray(item)) {
result = result.concat(flattenArray(item));
} else {
result.push(item);
}
}
return result;
}
99. Write a function to implement a simple pub/sub pattern.
Example:const element = document.getElementById("box");
for(let i = 0; i < 1000; i++) {
element.innerHTML = i;
}
Why?
Repeated DOM lookups are expensive.
80. How do you handle memory leaks?
Memory leaks happen when unused memory is not released.
Common Causes:
• Unremoved event listeners
• Global variables
• Timers not cleared
• Detached DOM elements
• Closures holding unused references
Example:
const interval = setInterval(() => {
console.log("Running");
}, 1000);
clearInterval(interval);
Best Practices:
• Remove listeners
• Clear timers
• Avoid unnecessary global variables
• Nullify unused references
DevTools:
Browser memory profiling tools help detect leaks.
Double Tap ❤️ For Part-9try {
console.log(a);
} catch(error) {
console.log("Error occurred");
} finally {
console.log("Execution completed");
}
Output:
Error occurred
Execution completed
Important:
finally runs whether an error occurs or not.
72. What is the Error object?
The Error object contains information about runtime errors.
Example:
try {
throw new Error("Something went wrong");
} catch(error) {
console.log(error.message);
}
Common Error Properties:
name
• Description: Error type
message
• Description: Error message
stack
• Description: Stack trace
Built-in Error Types:
• ReferenceError
• TypeError
• SyntaxError
• RangeError
73. How do you create custom errors?
Using classes or extending Error.
Example:
class ValidationError extends Error {
constructor(message) {
super(message);
this.name = "ValidationError";
}
}
throw new ValidationError("Invalid input");
Benefits:
• Better debugging
• More meaningful error handling
74. What are console.log, console.table, console.group?
These are debugging methods available in browser DevTools.
console.log()
Prints normal output.
console.log("Hello");
console.table()
Displays data in table format.
console.table([
{name: "Deepak", age: 25},
{name: "John", age: 30}
]);
console.group()
Groups related logs.
console.group("User Info");
console.log("Name: Deepak");
console.log("Age: 25");
console.groupEnd();
Benefit:
Cleaner debugging in large applications.
75. How do you use breakpoints and the debugger?
Breakpoints pause code execution for debugging.
Using debugger:
function test() {
let x = 10;
debugger;
console.log(x);
}
test();
How It Works:
• Browser pauses at debugger
• Inspect variables and execution flow
Browser DevTools Features:
• Step through code
• Watch variables
• Inspect call stack
• Monitor network requests
Interview Tip:
Very important skill for frontend developers.
76. What is performance profiling in DevTools?
Performance profiling helps identify slow operations and bottlenecks.
Browser DevTools Can Measure:
• Rendering performance
• JavaScript execution time
• Memory usage
• FPS drops
Common Tabs:
• Performance
• Memory
• Network
Why It Matters:
Helps optimize web applications and improve user experience.
77. How do you avoid blocking the main thread?
Heavy tasks can freeze the UI because JavaScript is single-threaded.
Solutions:
1. Use asynchronous operations
2. Break heavy tasks into chunks
3. Use Web Workers
4. Use setTimeout()
5. Optimize loops
Example:
setTimeout(() => {
heavyTask();
}, 0);
Why?
Allows browser to handle UI updates before running heavy code.
78. What is debouncing vs throttling?
Both optimize frequent function calls.
Debouncing
Runs function only after user stops triggering event.
Example Use Cases:
• Search input
• Resize events
function debounce(fn, delay) {
let timer;
return function() {
clearTimeout(timer);
timer = setTimeout(() => {
fn();
}, delay);
};
}
Throttling
Limits function execution to fixed intervals.
Example Use Cases:
• Scroll events
• Mouse movement
function throttle(fn, delay) {
let lastCall = 0;
return function() {
let now = Date.now();
if (now - lastCall >= delay) {
lastCall = now;
fn();
}
};
}
Difference:
Debounce
• Waits after last event
• Reduces extra calls
Throttle
• Executes at intervals
• Limits execution frequencyparent.addEventListener("click", function(event) {
console.log(event.target);
console.log(event.currentTarget);
});
Important:
In event delegation, target is very useful.
49. How do you prevent default behavior?
Using:
event.preventDefault();
Example:
Prevent form submission.
form.addEventListener("submit", function(event) {
event.preventDefault();
console.log("Form prevented");
});
Common Uses:
• Prevent page reload
• Prevent link navigation
• Custom form handling
50. How do you remove an event listener?
Using:
removeEventListener()
Example:
function handleClick() {
console.log("Clicked");
}
button.addEventListener("click", handleClick);
button.removeEventListener("click", handleClick);
Important:
The same function reference must be used while removing the listener.
Wrong Example:
button.removeEventListener("click", () => {});
This will not work because it creates a new function reference.
Double Tap ❤️ For Part-6* replaced by **:
🚀 JavaScript Interview Questions with Answers — Part 5
41. What is the DOM?
DOM stands for:
Document Object Model
It is a programming interface that represents an HTML document as a tree structure so JavaScript can access and manipulate webpage elements.
Example HTML:
<h1 id="title">Hello</h1>
JavaScript:
const heading = document.getElementById("title");
console.log(heading);
What You Can Do With DOM:
• Change text/content
• Change styles
• Add/remove elements
• Handle events
• Create interactive webpages
42. How do you select an element by id, class, or tag?
Select by ID
document.getElementById("title");
Select by Class
document.getElementsByClassName("box");
Select by Tag
document.getElementsByTagName("p");
Modern Selectors
querySelector()
Returns first matching element.
document.querySelector(".box");
querySelectorAll()
Returns all matching elements.
document.querySelectorAll(".box");
Interview Tip:
querySelector() is commonly used in modern JavaScript.
43. How do you change element text or HTML?
Change Text
Using textContent
const heading = document.getElementById("title");
heading.textContent = "Welcome";
Change HTML
Using innerHTML
heading.innerHTML = "<span>Hello</span>";
Difference:
Property: textContent → Purpose: Plain text only
Property: innerHTML → Purpose: HTML content
Important:
Avoid unsafe innerHTML with user input because of XSS security risks.
44. How do you add/remove/replace a DOM element?
Create Element
const div = document.createElement("div");
div.textContent = "New Element";
Add Element
document.body.appendChild(div);
Remove Element
div.remove();
Replace Element
const newElement = document.createElement("p");
newElement.textContent = "Updated";
div.replaceWith(newElement);
45. How do you listen to click, keyup, etc.?
Using addEventListener().
Click Event
const button = document.querySelector("button");
button.addEventListener("click", () => {
console.log("Button clicked");
});
Keyup Event
const input = document.querySelector("input");
input.addEventListener("keyup", () => {
console.log("Key released");
});
Common Events:
Event: click → Purpose: Mouse click
Event: keyup → Purpose: Key released
Event: keydown → Purpose: Key pressed
Event: submit → Purpose: Form submit
Event: mouseover → Purpose: Mouse hover
46. What is event delegation?
Event delegation is a technique where a parent element handles events for its child elements using event bubbling.
Example:
document.getElementById("list")
.addEventListener("click", function(event) {
if (event.target.tagName === "LI") {
console.log(event.target.textContent);
}
});
Benefits:
• Better performance
• Fewer event listeners
• Works for dynamically added elements
Interview Tip:
Very important concept in frontend interviews.
47. What is event bubbling vs capturing?
Events move through the DOM in two phases.
Event Bubbling
Event travels from child → parent.
Event Capturing
Event travels from parent → child.
Example:
div.addEventListener("click", () => {
console.log("Div clicked");
});
button.addEventListener("click", () => {
console.log("Button clicked");
});
If button clicked:
Button clicked
Div clicked
Enable Capturing:
div.addEventListener("click", handler, true);
Default:
JavaScript uses bubbling by default.