VIDEO 23 javascript
Thu Oct 31 2024 22:01:09 GMT+0000 (Coordinated Universal Time)
Saved by
@E23CSEU1151
////////*******THIS IN JS ************///////////
const user ={
username: "hitesh",
price: 999,
welcomeMessage: function(){
console.log(`${this.username}, welcome to website `);
// console.log(this); // it will print whole function
}
}
user.welcomeMessage() // hitesh, welcome to website
user.username = "harry"
user.welcomeMessage() // harry, welcome to website
console.log(this); // OUTPUT = {}
const chai = () => {
let username = "hitesh "
console.log(this);
}
chai()
///////////////********ARROW FUNCTION IN JS************//////////////
//// FIRST METHOD
const add2 = (num1 , num2 ) =>{ // implict function (when we use parethensis{} we have to write return also )
return num1 + num2
}
console.log(add2(2,3));
//// SECOND METHOD
const addtwo = (num1 , num2 ) => (num1 + num2) // explict function (when we don't use parethensis{} we have no need to write return also )
console.log(addtwo(5,3));
////////
content_copyCOPY
Comments