0% found this document useful (0 votes)
2 views3 pages

JavaScript Foundations DOM Async

This document provides a concise cheat-sheet for JavaScript covering three main areas: Foundations, DOM, and Async. It includes examples of variables, data types, functions, DOM manipulation, and asynchronous programming using promises and async/await. Additionally, there is an ultra-condensed version that summarizes these topics in approximately 15 lines.

Uploaded by

genuinelycool
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)
2 views3 pages

JavaScript Foundations DOM Async

This document provides a concise cheat-sheet for JavaScript covering three main areas: Foundations, DOM, and Async. It includes examples of variables, data types, functions, DOM manipulation, and asynchronous programming using promises and async/await. Additionally, there is an ultra-condensed version that summarizes these topics in approximately 15 lines.

Uploaded by

genuinelycool
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 foundations DOM Async [Link]

com/c/6941e927-6cc8-8320-bf97-fe36322137c6

ChatGPT Share Add people

give short javascript


1. fundations
2. DOM
3. Async
in consised form

Sure! Here's a concise cheat-sheet for JavaScript covering Foundations, DOM, and
Async:

1. Foundations
js Copy code

// Variables
let x = 10;
const y = 20;
var z = 30;

// Data types
let str = "hello"; // string
let num = 42; // number
let bool = true; // boolean
let arr = [1, 2, 3]; // array
let obj = {a:1, b:2}; // object
let n = null;
let u; // undefined

// Functions
function add(a,b){ return a+b; }
const sub = (a,b) => a-b;

// Loops
for(let i=0;i<5;i++){ [Link](i); }
[Link](v => [Link](v));

// Conditionals
if(x > y){ [Link]("x>y"); }
else if(x===y){ [Link]("x=y"); }
else{ [Link]("x<y"); }

// Destructuring
let [first, second] = arr;
let {a,b} = obj;

// Template literals
[Link](`Sum: ${x+y}`);

2. DOM (Document Object Model)


js Copy code

// Select elements
const el = [Link]('id');
const els = [Link]('.class');

// Manipulate content

1 of 3 17/12/2025, 05:10
JavaScript foundations DOM Async [Link]

[Link] = "Hello";
[Link] = "<b>Hello</b>";

// Change styles
[Link] = "red";

// Add event listeners


[Link]('click', () => [Link]("Clicked!"));

// Create elements
const div = [Link]('div');
[Link] = "New Div";
[Link](div);

// Remove element
[Link]();

3. Async (Promises, async/await, fetch)


js Copy code

// Promise
const p = new Promise((resolve, reject) => {
setTimeout(()=> resolve("Done"), 1000);
});
[Link](res => [Link](res))
.catch(err => [Link](err));

// Async/Await
async function getData() {
try {
const res = await fetch('[Link]
const data = await [Link]();
[Link](data);
} catch(e) {
[Link](e);
}
}
getData();

// setTimeout / setInterval
setTimeout(()=>[Link]("After 1s"), 1000);
const id = setInterval(()=>[Link]("Every 1s"), 1000);
clearInterval(id); // stop interval

If you want, I can also make an even shorter “1-page ultra-condensed JS cheat
sheet” for these three topics that fits in 10–15 lines.

Do you want me to do that?

ok

Here’s an ultra-condensed JavaScript cheat sheet in ~15 lines covering Foundations,


DOM, and Async:

2 of 3 17/12/2025, 05:10
JavaScript foundations DOM Async [Link]

js Copy code

// Foundations
let x=10, y=20; const z=30;
let arr=[1,2], obj={a:1,b:2};
const add=(a,b)=>a+b; for(let i=0;i<3;i++)[Link](i);
if(x>y)[Link]("x>y"); else [Link]("x<=y");
let [f,s]=arr, {a,b}=obj; [Link](`Sum: ${x+y}`);

// DOM
const el=[Link]('id');
[Link]="Hello"; [Link]="red";
[Link]('click',()=>[Link]("Clicked"));
const div=[Link]('div');
[Link]="New"; [Link](div); [Link]();

// Async
async function g(){try{let d=await (await fetch('[Link]
g();
setTimeout(()=>[Link]("1s"),1000);

If you want, I can make a one-line-per-concept version that’s even easier to


memorize for quick reference. Do you want me to do that?

3 of 3 17/12/2025, 05:10

You might also like