[Go to site: main page, start]

0% found this document useful (0 votes)
9 views8 pages

JavaScript Master Notes: A Complete Guide

itd goog
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)
9 views8 pages

JavaScript Master Notes: A Complete Guide

itd goog
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 Master Notes - Complete Guide

Variables & Declarations


var: function-scoped, can be redeclared
let: block-scoped, cannot be redeclared
const: block-scoped, cannot be reassigned

Example:
var a = 10; let b = 20; const c = 30;

Data Types
Primitive: String, Number, Boolean, Null, Undefined, Symbol, BigInt
Reference: Object, Array, Function

Example:
let str = 'hello'; let arr = [1,2,3]; let obj = {x:1};

Functions
Regular: function name() {}
Arrow: const f = () => {}
Default Parameters: function(x=10) {}
Example:
const greet = (name='User') => `Hi ${name}`;
JavaScript Master Notes - Complete Guide

Variables & Declarations


var: function-scoped, can be redeclared
let: block-scoped, cannot be redeclared
const: block-scoped, cannot be reassigned

Example:
var a = 10; let b = 20; const c = 30;

Data Types
Primitive: String, Number, Boolean, Null, Undefined, Symbol, BigInt
Reference: Object, Array, Function

Example:
let str = 'hello'; let arr = [1,2,3]; let obj = {x:1};

Functions
Regular: function name() {}
Arrow: const f = () => {}
Default Parameters: function(x=10) {}
Example:
const greet = (name='User') => `Hi ${name}`;
Loops
for, while, do..while - for repetition
for..in - keys in object
for..of - values in iterable

Example:
for (let i = 0; i < 5; i++) { [Link](i); }

Arrays
Built-in methods: push, pop, shift, unshift, map, filter, reduce, forEach

Example:
[1,2,3].map(x => x * 2); // [2,4,6]

Objects
Key-value pairs
Access with dot or bracket
Methods, nested objects

Example:
const user = {name: 'Mokshagna', age: 18};
ES6 Features
let, const
Arrow Functions: const fn = () => {}
Template literals: `Hello ${name}`
Destructuring: const {a, b} = obj;
Spread: [...arr]

Example:
const add = (a,b) => a+b;

DOM Manipulation
[Link], querySelector
innerHTML, textContent
createElement, appendChild

Example:
[Link]('#btn').addEventListener('click', fn);

Events
Event types: click, submit, keyup, etc.
Event delegation with target

You might also like