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

Javascript Cheat Sheet

This JavaScript cheat sheet covers essential concepts including variables, data types, operators, conditionals, loops, functions, arrays, objects, DOM basics, events, and the Fetch API. It provides examples for each topic to illustrate usage. The document serves as a quick reference for JavaScript syntax and functionality.

Uploaded by

rafia momota
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)
20 views2 pages

Javascript Cheat Sheet

This JavaScript cheat sheet covers essential concepts including variables, data types, operators, conditionals, loops, functions, arrays, objects, DOM basics, events, and the Fetch API. It provides examples for each topic to illustrate usage. The document serves as a quick reference for JavaScript syntax and functionality.

Uploaded by

rafia momota
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 Cheat Sheet

1. Variables

- let name = "Rafia";

- const age = 25;

- var city = "Dhaka";

2. Data Types

- String, Number, Boolean, Null, Undefined, Object, Array

- typeof "hello" => "string"

3. Operators

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

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

- Logical: &&, ||, !

4. Conditionals

if (age > 18) {

[Link]("Adult");

} else {

[Link]("Minor");

5. Loops

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

[Link](i);

while (x < 10) { ... }

for (let item of array) { ... }

6. Functions

function greet(name) {

return "Hello " + name;

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


JavaScript Cheat Sheet

7. Arrays

const fruits = ["Apple", "Banana"];

[Link]("Mango");

[Link](fruit => [Link]());

8. Objects

const person = { name: "Rafia", age: 25 };

[Link]([Link]);

9. DOM Basics

[Link]("id")

[Link](".class")

[Link] / innerHTML / value

10. Events

[Link]("click", function() {

[Link]("Clicked!");

});

11. Fetch API

fetch(url)

.then(res => [Link]())

.then(data => [Link](data))

.catch(err => [Link](err));

You might also like