This website works best with JavaScript enabled.
Bookmark
โšก๏ธ CLI & Setup
node -v
npm -v
npm init -y
๐Ÿงฉ Variables
let a = 1;
const b = 'text';
var c = true;
๐Ÿ“ Data Types
typeof 42;           // "number"
typeof 'hello';      // "string"
typeof true;         // "boolean"
typeof {};           // "object"
typeof [];           // "object"
typeof null;         // "object"
typeof undefined;    // "undefined"
typeof (() => {});   // "function"
๐Ÿ—๏ธ Functions
function sum(a, b) {
  return a + b;
}

const add = (a, b) => a + b;
๐Ÿ”„ Control Flow
if (x > 0) { ... }
else if (x < 0) { ... }
else { ... }

for (let i = 0; i < 5; i++) { ... }
while (condition) { ... }
do { ... } while (condition);

switch (value) {
  case 1: ...; break;
  default: ...;
}
๐Ÿ“ฆ Arrays
const arr = [1, 2, 3];
arr.push(4);
arr.pop();
arr.map(x => x * 2);
arr.filter(x => x > 1);
arr.reduce((a, b) => a + b, 0);
arr.includes(2);
arr.indexOf(3);
๐Ÿ—‚๏ธ Objects
const obj = { name: 'Alice', age: 30 };
obj.name;
obj['age'];
obj.city = 'NY';
delete obj.age;
Object.keys(obj);
Object.values(obj);
Object.entries(obj);
๐Ÿ›ก๏ธ String Methods
const str = 'Hello World';
str.length;
str.toUpperCase();
str.toLowerCase();
str.includes('World');
str.replace('World', 'JS');
str.split(' ');
str.slice(0, 5);
str.trim();
๐Ÿงช Event & DOM
document.getElementById('id');
document.querySelector('.class');
document.createElement('div');
element.addEventListener('click', fn);
element.classList.add('active');
element.style.color = 'red';
๐Ÿ”’ ES6+ Features
const [x, y] = [1, 2];                // Array destructuring
const { name, age } = obj;            // Object destructuring
const arr2 = [...arr, 5];             // Spread operator
const obj2 = { ...obj, city: 'LA' };  // Object spread
const greet = (name = 'Guest') => `Hi ${name}`;
๐Ÿ› ๏ธ Misc
console.log('Log');
setTimeout(() => {}, 1000);
setInterval(() => {}, 1000);
JSON.stringify(obj);
JSON.parse('{"a":1}');
HTML
Latex

Want to update?

Subscribe to my blog to receive the latest updates from us.

Monthly articles
New articles will be created every month.
No spam
All notifications are notified to you, not spam or advertising.