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

JavaScript Basics CheatSheet

This cheat sheet covers the basics of JavaScript, including variable declarations, data types, functions, conditionals, loops, arrays, objects, DOM manipulation, events, and ES6 features. It provides examples for each topic, highlighting key syntax and functionality. The document serves as a quick reference for fundamental JavaScript concepts and practices.
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 views2 pages

JavaScript Basics CheatSheet

This cheat sheet covers the basics of JavaScript, including variable declarations, data types, functions, conditionals, loops, arrays, objects, DOM manipulation, events, and ES6 features. It provides examples for each topic, highlighting key syntax and functionality. The document serves as a quick reference for fundamental JavaScript concepts and practices.
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/ 2

JavaScript Basics Cheat Sheet

1. VARIABLES

let name = 'Alice'; // can change later

const age = 25; // constant

var city = 'Delhi'; // older style (avoid)

2. DATA TYPES

String: 'hello', Number: 42, Boolean: true, false

Array: [1, 2, 3], Object: {name: 'Alice', age: 25}

3. FUNCTIONS

function greet(name) { return 'Hello ' + name; }

const greet = (name) => `Hello ${name}`;

4. CONDITIONALS

if (age >= 18) { console.log('Adult'); }

else { console.log('Minor'); }

5. LOOPS

for (let i = 0; i < 5; i++) { console.log(i); }

for (let item of arr) { console.log(item); }

6. ARRAYS

let fruits = ['apple', 'banana'];

fruits.push('orange'); // add to end

fruits.pop(); // remove last item

7. OBJECTS

let person = { name: 'Alice', age: 25 };

console.log(person.name); // 'Alice'
8. DOM MANIPULATION

document.getElementById('demo').innerText = 'Hello';

9. EVENTS (in HTML)

<button onclick="sayHello()">Click</button>

function sayHello() { alert('Hello!'); }

10. ES6 FEATURES

- Template Literal: `Hello, ${name}`

- Destructuring: let { name, age } = person;

- Spread: let newArr = [...oldArr];

You might also like