////////*******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)); ////////
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter