0% found this document useful (0 votes)
31 views2 pages

JavaScript Basics and ES6 Features Guide

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)
31 views2 pages

JavaScript Basics and ES6 Features Guide

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

JavaScript Notes

1. Introduction

JavaScript (JS) is a scripting language used to make web pages interactive. It can run on both
client-side (browser) and server-side ([Link]).

2. Syntax and Variables

var name = "John";

let age = 25;

const PI = 3.14;

3. Data Types

String: "Hello"

Number: 100, 3.14

Boolean: true / false

Object: {name: "John", age: 20}

Array: [1, 2, 3]

Undefined, Null

4. Operators

Arithmetic (+ - * / %), Assignment (= +=), Comparison (== === != > <), Logical (&& || !).

5. Control Structures

if (age >= 18) { [Link]("Adult"); } else { [Link]("Minor"); }

switch(day) { case 1: [Link]("Mon"); break; default: [Link]("Other"); }

for, while, and do-while loops are supported.

6. Functions

function add(a, b) { return a + b; }

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

7. Objects and Arrays

let person = {name: "Alice", age: 22};

let fruits = ["apple", "banana", "mango"];

8. DOM Manipulation

[Link]("demo").innerHTML = "Hello JavaScript!";

[Link]("p").[Link] = "blue";

9. Events

Click me

[Link]("btn").addEventListener("click", () => alert("Clicked!"));

10. Timing Functions

setTimeout(() => [Link]("After 2s"), 2000);


setInterval(() => [Link]("Every 1s"), 1000);

11. ES6 Features

Template Literals: `Hello ${name}`

Destructuring: const {name, age} = person;

Spread Operator: [...arr1, ...arr2]

Arrow Functions, Promises, Async/Await.

12. Example

let numbers = [1, 2, 3, 4, 5];

let squares = [Link](n => n * n);

[Link](squares);

You might also like