0% found this document useful (0 votes)
217 views11 pages

JavaScript Syntax Cheat Sheet PDF

The document provides an overview of basic JavaScript concepts like variables, data types, conditional statements, loops, functions, arrays, objects, DOM manipulation, event handling, and asynchronous programming using promises. Code examples are included to demonstrate each concept.

Uploaded by

toxiccoder2023
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)
217 views11 pages

JavaScript Syntax Cheat Sheet PDF

The document provides an overview of basic JavaScript concepts like variables, data types, conditional statements, loops, functions, arrays, objects, DOM manipulation, event handling, and asynchronous programming using promises. Code examples are included to demonstrate each concept.

Uploaded by

toxiccoder2023
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
  • Introduction to JavaScript
  • Basic Syntax in JavaScript
  • Variables and Types in JavaScript
  • Conditional Statements in JavaScript
  • Loops in JavaScript
  • Functions in JavaScript
  • Arrays in JavaScript
  • Objects in JavaScript
  • DOM Manipulation in JavaScript
  • Event Handling in JavaScript
  • Asynchronous Programming in JavaScript

Let’s Learn

JavaScript
Bhavin Thummar

(function repeat() {
eat();
sleep();
love_yourself();
repeat();
})();

#JavaScript #Programming
Basic syntax in
JavaScript

// JavaScript basic syntax


Let variable = "Hello, World!";
[Link](variable);
// Output : Hello, World!
Variables and Types in
JavaScript

// Variables and Types


Let age = 25; // number
let temperature = -10.5; // number
let name = "John"; // string
let isStudent = true; // boolean
let fruits = ["Apple", "Banana", "Orange"]; // object
let person = {
name: "John", age: 25, isStudent: true
}; // object
function greet(name) { return "Apple"; } // function
let job; // undefined
let result = null; // object
const id = Symbol('id'); // symbol
Conditional Statements in
JavaScript

// Conditional Statements
let temperature = 25;
if (temperature > 30) {
[Link]("It's hot outside!");
} else if (temperature > 20) {
[Link]("It's warm outside.");
} else {
[Link]("It's cold outside!");
}
// Output : It's warm outside.
Loops in
JavaScript

// Loops
for ( let i > 0; i < 5; i++) {
[Link]("Count: ", i);
}
// Output :
Count: 0
Count: 1
Count: 2
Count: 3
Count: 4
Functions in
JavaScript

// Functions
function greet(name) {
return "Hello, " + name + "!";
}
[Link](greet("Alice"));
// Output : Hello, Alice!
Arrays in
JavaScript

// Arrays
let fruits = ["Apple", "Banana", "Orange"];

[Link](fruits);
// Output : ['Apple', 'Banana', 'Orange']

[Link]([Link]);
// Output : 3
Objects in
JavaScript

// Objects
let person = {
name: "John",
age: 30,
isStudent: false
};
[Link]([Link]);
// Output : John
[Link](pe
[Link]);
// Output : 30
[Link](pe
[Link]
udent);
// Output : false
DOM Manipulation in
JavaScript

// DOM Manipulation
let heading = [Link]("h1");
[Link] = "Hello, World!";
[Link](heading);
// Output : <h1>Hello, World!</h1>

DOM Manipulation: JavaScript's ability to


modify webpage content and structure
dynamically.
Event Handling in
JavaScript

// Event Handling
let button = [Link]("button");
[Link]("click", function() {
[Link]("Button clicked!");
});
// Output : Button clicked!

Event Handling: JavaScript's capability to


respond to user actions on a webpage, such as
clicks or keypresses, by triggering predefined
functions or actions.
Asynchronous Programming in
JavaScript

// Asynchronous Programming (Promise)


function getData() {
return new Promise((resolve, reject) => {
// Simulating asynchronous task
setTimeout(() => {
resolve("Data fetched successfully!");
}, 2000);
});
}
getData().then(data => {
[Link](data);
});

(function repeat() {
eat();
sleep();
love_yourself();
repeat();
})();
Bhavin Thummar
Bhavin Thummar
Let’s Learn
JavaScript
// JavaScript basic syntax 
Let variable = "Hello, World!";
 console.log(variable);
// Output : Hello, World!
Basic syntax in
Variables and Types in
JavaScript
// Variables and Types 
Let age = 25; // number
let temperature = -10.5; // number
let nam
// Conditional Statements
// Conditional Statements
let temperature = 25;
if (temperature > 30) {
    console.log("It's hot o
// Loops
// Loops
for ( let i > 0; i < 5; i++) {
    console.log("Count: ", i);
}
// Output : 
Count: 0
Count: 1
Count: 2
Cou
// Functions
// Functions
function greet(name) {
    return "Hello, " + name + "!";
}
console.log(greet("Alice"));
// Output
// Arrays
// Arrays
let fruits = ["Apple", "Banana", "Orange"];
console.log(fruits);
// Output : ['Apple', 'Banana', 'Orange'
// Objects
// Objects
let person = {
    name: "John",
    age: 30,
    isStudent: false
};
console.log(person.name);
// Outp
// DOM Manipulation
// DOM Manipulation
let heading = document.createElement("h1");
heading.textContent = "Hello, World!";
do
// Event Handling
// Event Handling
let button = document.querySelector("button"); button.addEventListener("click", function(

You might also like