Java Script
Declaration
function greet() {
console.log("Hello");
}
Expression
const greet = function() {
console.log("Hello");
}
const add = (a, b) => a + b;
console.log(add(2,3));
Output
5
A function passed as an argument to another function.
function greet(name, callback) {
console.log("Hi " + name);
callback();
}
greet("Siva", function() {
console.log("Welcome");
});
let arr = [10,20,30];
for(let i=0;i<arr.length;i++){}
for(let value of arr){}
let obj = {name:"Siva"};
for(let key in obj){}
DOM (Document Object Model) represents the HTML document as objects.
Example
document.getElementById("title");
document.getElementById("id");
document.querySelector(".box");
document.querySelectorAll("p");
element.innerHTML = "<b>Hello</b>";
Displays bold text.
element.textContent = "<b>Hello</b>";
Displays the actual tags as text.