0% found this document useful (0 votes)
3 views4 pages

Bilingual JavaScript Notes

this is best notes for javasfbdkfjdnm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Bilingual JavaScript Notes

this is best notes for javasfbdkfjdnm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Notes (Bilingual: English + Hindi)

1. Introduction
Definition (English): JavaScript is a scripting language used to create dynamic and interactive
web pages.
Definition (Hindi): JavaScript ek scripting language hai jo dynamic aur interactive web pages
banane ke liye use hoti hai.
Syntax:
console.log('Hello JavaScript');
Example:
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Hello from JavaScript");
</script>
</body>
</html>
Output: Console → Hello JavaScript Webpage → Hello from JavaScript

2. Variables & Data Types


Definition (English): Variables are containers for storing data values. Types: var, let, const.
Definition (Hindi): Variables data store karne ke containers hote hain. Types: var, let, const.
Syntax:
var x = 5;
let y = 'Hello';
const pi = 3.14;
Example:
console.log(x);
console.log(y);
console.log(pi);
Output: 5 Hello 3.14

3. Operators
Definition (English): Operators are symbols that perform operations on values and variables.
Definition (Hindi): Operators woh symbols hote hain jo values aur variables par operations
perform karte hain.
Syntax:
let x=10, y=3;
Example:
console.log(x+y);
console.log(x-y);
console.log(x*y);
console.log(x/y);
Output: 13 7 30 3.333...

4. Conditional Statements
Definition (English): Used to make decisions in code (if, else, switch).
Definition (Hindi): Decision making ke liye use hota hai (if, else, switch).
Syntax:
if(condition){ ... } else { ... }
Example:
let num = 5;
if(num>0){ console.log('Positive'); } else { console.log('Negative'); }
Output: Positive

5. Loops
Definition (English): Loops are used to repeat a block of code multiple times.
Definition (Hindi): Loops ka use ek block of code ko bar-bar chalane ke liye hota hai.
Syntax:
for(initialization; condition; increment){ ... }
Example:
for(let i=1;i<=3;i++){ console.log(i); }
Output: 1 2 3

6. Functions
Definition (English): Functions are blocks of code designed to perform a task.
Definition (Hindi): Functions ek block of code hote hain jo specific kaam ke liye likhe jaate hain.
Syntax:
function functionName(params){ return value; }
Example:
function add(a,b){ return a+b; }
console.log(add(2,3));
Output: 5

7. Arrays
Definition (English): Arrays are used to store multiple values in a single variable.
Definition (Hindi): Arrays ek variable me multiple values store karne ke liye use hote hain.
Syntax:
let arr = [1,2,3];
Example:
let fruits=['Apple','Banana'];
fruits.push('Mango');
console.log(fruits);
Output: Apple,Banana,Mango

8. Strings
Definition (English): Strings are sequences of characters enclosed in quotes.
Definition (Hindi): Strings characters ka sequence hote hain jo quotes me likhe jaate hain.
Syntax:
let str = 'Hello';
Example:
let s='JavaScript';
console.log(s.toUpperCase());
Output: JAVASCRIPT

9. Objects
Definition (English): Objects are collections of key-value pairs.
Definition (Hindi): Objects key-value pairs ka collection hote hain.
Syntax:
let obj = {key:value};
Example:
let person={name:'Sarfaraz', age:20};
console.log(person.name);
Output: Sarfaraz

10. DOM Manipulation


Definition (English): DOM is used to access and change HTML elements dynamically.
Definition (Hindi): DOM ka use HTML elements ko dynamically access aur change karne ke liye
hota hai.
Syntax:
document.getElementById('id').innerHTML='text';
Example:
<p id='demo'></p>
<script>
document.getElementById('demo').innerHTML='Hello';
</script>
Output: Page par → Hello

11. Events
Definition (English): Events are actions that can be handled (click, hover, etc.).
Definition (Hindi): Events wo actions hote hain jo handle kiye ja sakte hain (click, hover, etc.).
Syntax:
<button onclick='myFunc()'>Click</button>
Example:
<button onclick="alert('Hi')">Click</button>
Output: Shows alert box: Hi

12. ES6 Features


Definition (English): Modern JavaScript features include let/const, arrow functions, template
literals.
Definition (Hindi): Modern JavaScript features me let/const, arrow functions, template literals aate
hain.
Syntax:
let [a,b] = [1,2];
const add=(x,y)=>x+y;
Example:
console.log(`Sum = ${add(2,3)}`);
Output: Sum = 5

13. Asynchronous JS
Definition (English): Handles tasks that take time using callbacks, promises, async/await.
Definition (Hindi): Time-taking tasks ko handle karne ke liye callbacks, promises, async/await ka
use hota hai.
Syntax:
setTimeout(()=>{...},1000);
Example:
setTimeout(()=>console.log('Hello after 1s'),1000);
Output: Prints after 1s → Hello after 1s

14. Classes
Definition (English): Classes are templates for creating objects (OOP concept).
Definition (Hindi): Classes objects banane ke templates hote hain (OOP concept).
Syntax:
class ClassName { constructor(){...} method(){...} }
Example:
class Animal{ constructor(name){this.name=name;} speak(){console.log(this.name);} }
let dog=new Animal('Dog'); dog.speak();
Output: Dog

15. JSON & Storage


Definition (English): JSON is used for data exchange. localStorage stores data in browser.
Definition (Hindi): JSON data exchange ke liye use hota hai. localStorage browser me data store
karta hai.
Syntax:
JSON.stringify(obj); localStorage.setItem(key,value);
Example:
localStorage.setItem('user','Sarfaraz');
console.log(localStorage.getItem('user'));
Output: Sarfaraz

16. Error Handling


Definition (English): try-catch is used to handle errors in JS.
Definition (Hindi): try-catch ka use errors handle karne ke liye hota hai.
Syntax:
try { ... } catch(error) { ... }
Example:
try{ let x=undefined; console.log(x.name);} catch(e){ console.log('Error found'); }
Output: Error found

17. Advanced Topics


Definition (English): Closures, hoisting, callbacks, higher-order functions.
Definition (Hindi): Closures, hoisting, callbacks, higher-order functions.
Syntax:
function outer(){ let x=10; function inner(){console.log(x);} return inner;}
Example:
let f=outer(); f();
Output: 10

You might also like