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

JavaScript Essentials

JavaScript Essentials

Uploaded by

youssefbouh2
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)
16 views4 pages

JavaScript Essentials

JavaScript Essentials

Uploaded by

youssefbouh2
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 Essentials: From Basics to

Advanced
1. Introduction
• JavaScript (JS) is a high-level, interpreted, dynamic language primarily used for web
development.
• First released in 1995 by Brendan Eich.
• Key features:
o Runs in browsers and servers (Node.js)
o Event-driven, functional, and object-oriented
o Dynamic typing and first-class functions

2. Basic Syntax
console.log("Hello, JavaScript!");

let name = "Alice";


const age = 25;
var isActive = true;

• Variables: let, const, var


• Data types: Number, String, Boolean, Object, Array, Null, Undefined
• Control flow: if, else, switch, for, while, do-while

3. Functions
function add(a, b) {
return a + b;
}

const multiply = (a, b) => a * b;

console.log(add(5, 3));
console.log(multiply(4, 2));

• Function declarations and arrow functions


• Functions are first-class objects
• Can return other functions

Confidential – Oracle Internal


4. Objects & Arrays
let person = { name: "Alice", age: 25 };
console.log(person.name);

let numbers = [1, 2, 3, 4, 5];


numbers.push(6);
console.log(numbers);

• Objects: key-value pairs


• Arrays: ordered collections, methods like map, filter, reduce

5. ES6+ Features
• Destructuring

const { name, age } = person;

• Template literals

console.log(`Hello, ${name}!`);

• Modules

import { myFunc } from './module.js';

• Spread & Rest

const arr2 = [...numbers, 6, 7];

6. Asynchronous JS
• Callbacks

setTimeout(() => console.log("Delayed"), 1000);

• Promises

fetch('https://api.example.com')
.then(res => res.json())
.then(data => console.log(data));

• Async/Await

Confidential – Oracle Internal


async function fetchData() {
const res = await fetch('https://api.example.com');
const data = await res.json();
console.log(data);
}

7. DOM Manipulation
document.getElementById("myButton").addEventListener("click", () => {
alert("Button clicked!");
});

• document.querySelector, addEventListener, innerHTML


• Dynamically update the page content

8. Error Handling
try {
let result = riskyOperation();
} catch (error) {
console.error(error);
} finally {
console.log("Execution finished");
}

• try-catch-finally
• Throw custom errors: throw new Error("Oops!")

9. Advanced Tips
• Use const for immutability
• Prefer arrow functions for callbacks
• Learn event loop and async behavior
• Use array methods for clean code

10. Resources
• MDN JavaScript Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript
• Books: Eloquent JavaScript, You Don’t Know JS
• Practice: LeetCode, HackerRank, Codewars

Confidential – Oracle Internal


Confidential – Oracle Internal

You might also like