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

Javascript

This document provides a concise cheat sheet for JavaScript, outlining key concepts, syntax, and their uses. It covers essential topics such as alerts, logging, variables, functions, event handling, DOM manipulation, data types, and output methods. Each concept is illustrated with examples for clarity and quick reference.
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 views4 pages

Javascript

This document provides a concise cheat sheet for JavaScript, outlining key concepts, syntax, and their uses. It covers essential topics such as alerts, logging, variables, functions, event handling, DOM manipulation, data types, and output methods. Each concept is illustrated with examples for clarity and quick reference.
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

🎁 Simple Example – JS in Action


javascript
🧠 JavaScript All-Rounder Cheat Sheet
Concept Syntax Use

Alert alert("Hi"); Show popup message to user

Log [Link]("msg"); Debug info in browser's dev console

Variable let x = 10; Store data

Function function sayHi() { alert("Hi"); } Group reusable code

Call Function sayHi(); Run function

<button
Event Run JS on button click
onclick="sayHi()">Click</button>

Get Element [Link]("id") Access HTML elements

Change Content .innerHTML = "New"; Update page text

If/Else if (x > 10) { } else { } Decision making

Loop for (let i = 0; i < 5; i++) { } Repeat task multiple times

Array let arr = [1, 2, 3]; Store list of items

Object let user = {name: "John", age: 18}; Group data under one name

DOM Change [Link] = "red"; Change style with JavaScript

if ([Link] == "") { alert("Enter


Form Validation Check form before submit
data"); }
javascript
javascript
🔹 4. Data Types
Type Example

String "Hello"

Number 5, 3.14

Boolean true, false

Array [1, 2, 3]

Object {name: "John", age: 20}

🔹 2. Output in JS
Method Purpose Example

alert() Show popup alert alert("Hello!");

Log to developer [Link]("Deb


[Link]()
console ug info");

Write to the web [Link]("


[Link]()
page Hi");

You might also like