Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

javascript basics

Uploaded by

sehan3061
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

javascript basics

Uploaded by

sehan3061
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

New chat

javascript basis in small words

Here’s a simple overview of JavaScript basics:

1. Variables: Store data.


`let`, `const`, `var` (e.g., `let x = 10;`).
2. Data Types:
String (`"hello"`), Number (`42`), Boolean (`true`/`false`), Array (`[1, 2, 3]`), Object (`{
key: "value" }`).
3. Operators: Perform actions.
`+`(add), `-` (subtract), `*` (multiply), `/` (divide), `%` (remainder).
4. Functions: Reusable blocks of code.

javascript

function greet(name) {
return `Hello, ${name}!`;
}

5. Conditionals: Make decisions.

javascript

if (x > 10) {
console.log("Big number");
} else {
console.log("Small number");
}

6. Loops: Repeat actions.


`for`, `while`, `do...while`.

javascript

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


console.log(i);
}

7. DOM Manipulation: Interact with the webpage.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 1/2
javascript

document.getElementById("myId").innerHTML = "Hello!";

8. Events: Respond to user actions.

javascript

button.addEventListener("click", () => {
alert("Clicked!");
});

9. Objects: Store complex data.

javascript

const car = { brand: "Toyota", color: "red" };

10. ES6 Features: Modern syntax.


Arrow functions: `const sum = (a, b) => a + b;`
Template literals: `Hello, ${name}!`

Would you like examples or elaboration on any of these?

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 2/2

You might also like