person = {name : "john",
age: [1,2,[[5,a,7,8]],3,4],
// func : a, name : "peter"};
func : () =>{
console.log("function inside object");
}
};
console.log(person.age[2][0][1]());
console.log(person.name);
function a() {
console.log("hello");
return 1;//if no return 1 > undefined
}
a = 10;//if var a = 10 > undefined
console.log(a);
person.func();
const b = function () {
console.log("I am from function b");
}
b();
console.log(b);
(function() {
console.log("i am from IIFE")
})()
//simply arrow function
const c =()=> {
console.log("i am arrow function");
}
const d = x => x**2; // arrow function (simply function (x)=> {x**2};
console.log(d(2));
//multiple parameters
const e = (x,y) => {
console.log(x,y);
return x = y;
}
add = a=> b=> a + b;
console.log(add(1)(2));
add1 = function (a) {
return function (b) {
return a+b;
}
}
console.log(add1(1)(2))
function h(x) {
x();
}
function j() {
console.log("j")
}
h(j)