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

JavaScript Syntax and Operators Guide

This JavaScript cheatsheet provides a quick reference for basic syntax, operators, conditional statements, and loops. It includes examples for declaring variables, performing arithmetic, and using control structures like if statements and loops. The document serves as a concise guide for essential JavaScript concepts and operations.

Uploaded by

Nirmal Gusain
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)
10 views2 pages

JavaScript Syntax and Operators Guide

This JavaScript cheatsheet provides a quick reference for basic syntax, operators, conditional statements, and loops. It includes examples for declaring variables, performing arithmetic, and using control structures like if statements and loops. The document serves as a concise guide for essential JavaScript concepts and operations.

Uploaded by

Nirmal Gusain
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 Cheatsheet

1. Basic Syntax

Operation Syntax/Example

Declare variable (ES6) let x = 5; const y = 10;

Console output [Link]("Hello World");

Data types String, Number, Boolean, Object, Array, Null, Undefined, Symbol

Type checking typeof x

2. Operators

Operator Description Example

Arithmetic + - * / % ++ -- let sum = 5 + 3;

Assignment = += -= *= /= x += 5;

Comparison == === != !== > < >= <= x === 10

Logical && || ! if (x > 5 && y < 10)

Ternary condition ? expr1 : expr2 let status = age > 18 ? 'adult' : 'minor';

3. Conditional Statements

if (condition) {

// code if true

} else if (condition) {

// code if true

} else {

// code if all false

switch (value) {

case 1:

// code for case 1

break;
JavaScript Cheatsheet

case 2:

// code for case 2

break;

default:

// code if no cases match

4. Loops

Loop Example

for loop for (let i = 0; i < 5; i++) { [Link](i); }

while loop let i = 0; while (i < 5) { [Link](i); i++; }

do...while let i = 0; do { [Link](i); i++; } while (i < 5);

for...of (arrays) for (let value of array) { [Link](value); }

for...in (objects) for (let key in object) { [Link](key, object[key]); }

You might also like