Muhammad saifullah
*๐ JavaScript Events*
Events make websites interactive. They allow JavaScript to respond to user actions like clicking a button, submitting a form, or typing in an input field.
Example actions:
- Clicking a button
- Submitting a form
- Hovering over an element
- Typing in a textbox
JavaScript listens for these actions and runs code when they happen.
*๐น 1. What is an Event?*
An event is an action that occurs in the browser.
Examples:
- click
- submit
- change
- update
Example:
button.addEventListener("click", function(){
console.log("Button clicked");
});
When the button is clicked โ the function runs.
*๐น 2. Event Listener*
The most common way to handle events.
Syntax:
element.addEventListener("event", function);
Example:
document.getElementById("btn")
.addEventListener("click", () => {
alert("Button clicked!");
});
*๐น 3. Common JavaScript Events*
- click: When user clicks an element
- submit: When form is submitted
- change: When input value changes
- keydown: When a key is pressed
- mouseover: When mouse enters element
Example:
input.addEventListener("change", function(){
console.log("Value changed");
});
*๐น 4. Event Object*
When an event occurs, JavaScript creates an event object containing information about the event.
Example:
button.addEventListener("click", function(event){
console.log(event);
});
The event object contains details like:
- target element
- mouse position
- key pressed
*๐น 5. Event Bubbling*
Events propagate from the child element to the parent element.
Example:
button โ div โ body โ html
If a button inside a div is clicked, the event may trigger on:
- button
- div
- body
This is called event bubbling.
*๐น 6. Event Delegation*
Instead of attaching events to many elements, attach one event to the parent element.
Example:
document.querySelector("ul")
.addEventListener("click", function(event){
console.log(event.target);
});
Benefits:
- Better performance
- Handles dynamically added elements
*โญ Most Important Event Concepts*
Focus on these first:
โ
click event
โ
addEventListener()
โ
event object
โ
event bubbling
โ
event delegation
These are used in almost every JavaScript project.
*๐ฏ Real Example*
HTML:
Click Me
JavaScript:
document.getElementById("btn")
.addEventListener("click", () => {
alert("Hello!");
});
๐ When the user clicks the button โ alert appears.
*Double Tap โฅ๏ธ For More*
โ
*JavaScript Basics* ๐โจ
The journey to becoming a front-end or full-stack developer starts with strong JavaScript fundamentals. Here's your starter kit:
*1๏ธโฃ Syntax*
โ JavaScript uses `{}` to define code blocks
โ Statements end with `;` (optional but recommended)
```javascript
if (5 > 3) {
console.log("Five is greater than three");
}
```
*2๏ธโฃ Variables*
โ `var`, `let`, and `const` used to declare variables
```javascript
let name = "Alice";
const age = 25;
var height = 5.6;
```
*3๏ธโฃ Data Types*
โ JavaScript supports:
- *String* โ `"Hello"`
- *Number* โ `100`, `19.99`
- *Boolean* โ `true`, `false`
- *Undefined* โ variable declared but not assigned
- *Null* โ no value
- *Object*, *Array*, *Function*
*4๏ธโฃ Type Casting*
โ Implicit and explicit type conversion
```javascript
let x = Number("5"); // string to number
let y = String(100); // number to string
let z = parseFloat("3.14");
```
*5๏ธโฃ Input & Output*
โ Browser-based input/output
```javascript
let name = prompt("Enter your name:");
alert("Hello " + name);
console.log("Name entered:", name);
```
*6๏ธโฃ Comments*
โ Single-line and multi-line
```javascript
// This is a single-line comment
/* This is
a multi-line comment */
```
*7๏ธโฃ Basic Operators*
โ `+`, `-`, `*`, `/`, `%`, `**` for math
โ `==`, `===`, `!=`, `!==`, `>`, `=`, `
๐ฅ *20 JavaScript Interview Questions*
*1. What are the different data types in JavaScript*
โข String, Number, Boolean, Undefined, Null, Object, Symbol, BigInt
Use `typeof` to check a variableโs type.
*2. What is the difference between == and ===*
โข `==` compares values with type coercion
โข `===` compares both value and type (strict equality)
*3. What is hoisting in JavaScript*
Variables and function declarations are moved to the top of their scope before ex*****on.
Only declarations are hoisted, not initializations.
*4. What is a closure*
A function that remembers variables from its outer scope even after the outer function has finished executing.
Example:
```js
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const counter = outer();
counter(); // 1
```
*5. What is the difference between var, let, and const*
โข `var`: function-scoped, can be re-declared
โข `let`: block-scoped, can be updated
โข `const`: block-scoped, cannot be re-assigned
*6. What is event delegation*
Using a single event listener on a parent element to handle events from its child elements using `event.target`.
*7. What is the use of promises in JavaScript*
Handle asynchronous operations.
States: pending, fulfilled, rejected
Example:
```js
fetch(url)then(res => res.json())catch(err => console.error(err));
```
*8. What is async/await*
Syntactic sugar over promises for cleaner async code
Example:
```js
async function getData() {
const res = await fetch(url);
const data = await res.json();
console.log(data);
}
```
*9. What is the difference between null and undefined*
โข `null`: intentional absence of value
โข `undefined`: variable declared but not assigned
*10. What is the use of arrow functions*
Shorter syntax, no own `this` binding
Example:
```js
const add = (a, b) => a + b;
```
*11. What is the DOM*
Document Object Model โ represents HTML as a tree structure. JavaScript can manipulate it using methods like `getElementById`, `querySelector`, etc.
*12. What is the difference between call, apply, and bind*
โข `call`: invokes function with arguments passed individually
โข `apply`: invokes function with arguments as array
โข `bind`: returns a new function with bound context
*13. What is the use of setTimeout and setInterval*
โข `setTimeout`: runs code once after delay
โข `setInterval`: runs code repeatedly at intervals
*14. What is the difference between stack and heap*
โข Stack: stores primitive values and function calls
โข Heap: stores objects and reference types
*15. What is the use of the spread operator (...)*
Expands arrays/objects or merges them
Example:
```js
const arr = [1, 2];
const newArr = [...arr, 3]; // [1, 2, 3]
```
*16. What is the difference between map and forEach*
โข `map`: returns a new array
โข `forEach`: performs action but returns undefined
*17. What is the use of localStorage and sessionStorage*
โข `localStorage`: persists data even after browser is closed
โข `sessionStorage`: persists data only for session
*18. What is a prototype in JavaScript*
Every object has a prototype โ an object it inherits methods and properties from. Enables inheritance.
*19. What is the difference between synchronous and asynchronous code*
โข Synchronous: executes line by line
โข Asynchronous: executes independently, doesnโt block main thread
*20. What are modules in JavaScript*
Used to split code into reusable pieces
Example:
```js
// file.js
export const greet = () => "Hello";
// main.js
import { greet} from './file.js';
```
โค๏ธ *React for more Interview Resources*
Consistency Beats Motivation:
I waited for motivation to learn new tools.
Sometimes it cameโฆ mostly, it didnโt.
Then I switched to 20 mins daily practice.
Small steps โ Big growth.
Motivation fades.
Consistency builds careers.
Whatโs one skill youโre consistently improving right now?
hashtag hashtag hashtag hashtag hashtag hashtag hashtag hashtag hashtag
18/08/2025
๐ ๐ฆ๐ผ๐ณ๐ ๐ฆ๐ธ๐ถ๐น๐น๐ ๐๐๐ฒ๐ฟ๐ ๐ช๐ฒ๐ฏ ๐๐ฒ๐๐ฒ๐น๐ผ๐ฝ๐ฒ๐ฟ ๐ ๐๐๐ ๐๐ฒ๐ฎ๐ฟ๐ป:
Being a web developer isnโt just about writing clean code or mastering frameworks. Success in this field also depends heavily on soft skills that make collaboration and growth possible.
Here are some essentials every developer should focus on:
๐น Communication โ Explaining complex ideas in simple terms to clients, teammates, or non-technical stakeholders.
๐น Problem-Solving Mindset โ Debugging isnโt just about code; itโs about finding creative solutions under pressure.
๐น Teamwork โ Great projects are built when developers collaborate effectively, not in isolation.
๐น Adaptability โ Tech changes fast. The ability to learn and adjust quickly is key to staying relevant.
๐น Time Management โ Balancing deadlines, bug fixes, and feature requests requires discipline.
๐น Empathy โ Understanding user needs and client perspectives leads to better, human-centered solutions.
๐ก Mastering these soft skills alongside technical expertise will not only make you a better developer but also a valuable professional in any team.
๐ What soft skill do you think has helped you most as a developer?
17/08/2025
Pro Coders during serious debugging ๐ซข
17/08/2025
๐ก ๐ง๐ต๐ฒ ๐๐ฒ๐๐ ๐ช๐ฎ๐ ๐๐ผ ๐๐๐ธ ๐ณ๐ผ๐ฟ ๐๐ฒ๐น๐ฝ ๐ฎ๐ ๐ฎ ๐๐ฒ๐๐ฒ๐น๐ผ๐ฝ๐ฒ๐ฟ:
As developers, we all hit roadblocks. The difference between staying stuck and moving forward often comes down to how we ask for help.
Hereโs what Iโve learned works best:
โ
Be Specific โ Donโt just say โItโs not working.โ Share the exact error, code snippet, or unexpected behavior.
โ
Show Effort โ Mention what you already tried (Google searches, docs, debugging steps). This shows you respect the other personโs time.
โ
Ask Clear Questions โ Instead of โCan someone fix this?โ try โWhy does X happen when I do Y?โ
โ
Be Respectful โ A little politeness goes a long way. Everyoneโs busy, so gratitude matters.
When you ask better, you learn faster, and the person helping you feels valued too.
๐ How do you ask for help when youโre stuck on a coding problem?
*Quick JavaScript Cheatsheet* ๐
*Variables*
- `let x = 5;` (block-scoped)
- `const y = 10;` (constant)
- `var z = 15;` (function-scoped)
*Data Types*
- Number: `let num = 10;`
- String: `let str = "hello";`
- Boolean: `let isTrue = false;`
- Array: `let arr = ;`
- Object: `let obj = { name: "Amit", age: 25 };`
*Functions*
- Regular:
`function greet() { return "Hi!"; }`
- Arrow:
`const add = (a, b) => a + b;`
*Conditionals*
- `if (x > 5) { ... } else { ... }`
- Ternary:
`let result = x > 5 ? "Yes" : "No";`
*Loops*
- For:
`for (let i = 0; i < 5; i++) { ... }`
- While:
`while (x < 10) { ... }`
- ForEach (array):
`arr.forEach(item => console.log(item));`
*DOM Manipulation*
- Get element:
`document.getElementById("myId")`
- Change text:
`element.textContent = "New Text";`
- Add event:
`element.addEventListener("click", myFunc);`
*React โค๏ธ for more*
โ
100 Days JavaScript Roadmap โ 2025 ๐๐ก
๐ Daily: 1โ2 hours + hands-on coding practice
๐ Days 1โ10: JavaScript Basics
โ Set up editor & browser console
โ Variables: var, let, const
โ Data types: string, number, boolean, null, undefined
โ Basic operators & expressions
โ Conditionals: if, else, switch
โ Loops: for, while, do...while
๐ Days 11โ20: Functions, Arrays, Objects
โ Function declarations & expressions
โ Parameters, return values
โ Arrays & common methods (push, pop, map, filter)
โ Objects, properties, access & manipulation
โ Scope & hoisting
โ Mini project: Calculator or Guessing Game
๐ Days 21โ30: DOM & Events
โ DOM selection & manipulation
โ Adding/removing elements
โ Event listeners, handling clicks & forms
โ Basic form validation
โ Mini project: To-Do List App
๐ Days 31โ40: Modern JS & ES6+
โ Arrow functions
โ Template literals
โ Destructuring, spread/rest operators
โ Classes, OOP basics
โ Modules: import/export
โ Mini project: Notes App or Quiz App
๐ Days 41โ50: Asynchronous JavaScript
โ Callbacks, Promises
โ Async/await syntax
โ Fetch API & data from web
โ Handling JSON
โ Mini project: Weather App or News App
๐ Days 51โ60: Project Building & Storage
โ LocalStorage & sessionStorage
โ Small real-life projects (Expense Tracker, Clock, etc.)
โ Code refactoring & debugging
โ Using DevTools for troubleshooting
๐ Days 61โ70: Advanced Concepts
โ Prototypal inheritance
โ 'this', closures
โ Error handling: try/catch
โ Regular expressions
โ Higher-order functions, functional programming basics
๐ Days 71โ80: Framework Introduction
โ Basics of React or Node.js
โ Component structure, props, state (for React)
โ Writing a tiny full-stack or frontend app
๐ Days 81โ90: APIs & Real-World Data
โ Consuming public APIs
โ Building a personal portfolio project
โ SEO basics, accessibility tips
โ Project: Personal Portfolio, Movie App
๐ Days 91โ100: Version Control & Deployment
โ Git & GitHub basics
โ Push projects and portfolio to GitHub
โ Deploy using Netlify, Vercel, or GitHub Pages
โ Review, update, and share your projects
๐ Tap โค for more!
18/07/2025
๐น๏ธ UI/UX - css-tricks.com
๐น๏ธ API - restapitutorial.com
๐น๏ธ Python - python.org/doc
๐น๏ธ Node.js - nodejs.dev.
Welcome to Python.org The official home of the Python Programming Language
11/07/2025
๐ฃ Switch Case Tutorial in JavaScript
Looking to clean up those long if-else chains?
The switch statement is a powerful tool for writing clearer and more organized code.
๐ In this tutorial, youโll learn:
โ
When to use switch
โ
How it compares to if-else
โ
Real-world examples to boost your logic
Whether you're just starting out or brushing up your skills โ this one's for you!
๐ผ I BUILD HIGH-QUALITY CUSTOM WEB APPS FOR BUSINESSES
Whether you're a startup or an established brand, I help turn your ideas into fast, scalable, and user-friendly web applications โ built specifically for your business needs.
โ
Tailored Solutions
โ
Clean, Responsive Design
โ
Scalable Architecture
โ
Ongoing Support
๐ฌ Free Consultation Available
Letโs connect and take your business online โ the right way.
๐ฉ Message now to get started!
Check Pin Post
Click here to claim your Sponsored Listing.
Category
Address
Lahore
05450