Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

JavaScript_Notes

This document provides an overview of JavaScript, highlighting its role in web development and server-side applications. It covers key concepts such as variables, data types, operators, conditional statements, loops, functions, arrays, objects, DOM manipulation, events, ES6 features, JSON handling, and asynchronous programming with promises and async/await. Additionally, it lists useful methods for strings and arrays.

Uploaded by

Rsdkm minecraft
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 views

JavaScript_Notes

This document provides an overview of JavaScript, highlighting its role in web development and server-side applications. It covers key concepts such as variables, data types, operators, conditional statements, loops, functions, arrays, objects, DOM manipulation, events, ES6 features, JSON handling, and asynchronous programming with promises and async/await. Additionally, it lists useful methods for strings and arrays.

Uploaded by

Rsdkm minecraft
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

1. Introduction to JavaScript:

- JavaScript is a lightweight, interpreted programming language.

- Used mainly for web development.

- Runs in the browser (client-side) and also on servers (Node.js).

2. Variables:

- Declared using var, let, or const.

let x = 10;

const y = 20;

3. Data Types:

- Primitive: String, Number, Boolean, Null, Undefined, Symbol

- Non-Primitive: Object, Array

4. Operators:

- Arithmetic: +, -, *, /, %

- Comparison: ==, ===, !=, !==, >, <, >=, <=

- Logical: &&, ||, !

5. Conditional Statements:

if (condition) {

// code

} else if (condition) {

// code
} else {

// code

6. Loops:

for (let i = 0; i < 5; i++) {

console.log(i);

while (condition) {

// code

do {

// code

} while (condition);

7. Functions:

function add(a, b) {

return a + b;

const multiply = (a, b) => a * b;

8. Arrays:

let arr = [1, 2, 3];

console.log(arr[0]);
arr.push(4);

9. Objects:

let person = {

name: "John",

age: 30

};

console.log(person.name);

10. DOM Manipulation:

document.getElementById("demo").innerHTML = "Hello";

document.querySelector(".class").style.color = "red";

11. Events:

document.getElementById("btn").addEventListener("click", function() {

alert("Button clicked!");

});

12. ES6 Features:

- Arrow Functions

- Template Literals: `Hello ${name}`

- Destructuring

- Spread and Rest Operators

13. JSON:

let jsonString = JSON.stringify(obj);

let jsonObj = JSON.parse(jsonString);


14. Promises & Async/Await:

function fetchData() {

return new Promise((resolve, reject) => {

// async code

});

async function getData() {

let data = await fetchData();

console.log(data);

15. Useful Methods:

- String: length, toUpperCase(), includes()

- Array: map(), filter(), reduce(), forEach()

You might also like