let value = 4 let negvalue = -value console.log(negvalue); /*console.log(2+2); console.log(2-2); console.log(2*2); console.log(2**2); console.log(2/2); console.log(2%2);*/ let str1 = "hello " let str2 = "namastey" let str3 = str1 + str2 console.log(str1 + str2) /* javascript basic tricks*/ console.log(2+"3") //23 console.log("2"+"3") //23 console.log("1"+2+2) //122 console.log(1+2+'2') //32 /* bad performance*/ console.log(+true);//true console.log(+"");//fales let gamecounter = 100 gamecounter++; // post increment and pre increment gives a same answer console.log(gamecounter);
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