How to console.log the name of the variable as well as its value
This tweet from @wesbos is a great tip, anything that makes working with JavaScript in Developer Tools for your browser of choice has got to be a bonus, right?
Wrap your console.log arguments in an object literal to print the variable name along with its value.
— Daniel Stefanovic (@DaniStefanovic) June 27, 2018
console.log(isLoggedIn)
console.log({ isLoggedIn })
Still one of my favorite tips from @wesbos. So simple but effective 💪 pic.twitter.com/wMrDt4JDJ4
;Rather than going to the effort of writing:
console.log('isLoggedIn: ' + isLoggedIn);
You can short-hand it by writing:
console.log({isLoggedIn});
Simples!
About Rob
I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.
My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.
My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.