How to console.log the name of the variable as well as its value

JavaScript object literal based console logging goodness!

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?

;Rather than going to the effort of writing:

console.log('isLoggedIn: ' + isLoggedIn);

You can short-hand it by writing:



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.

No Comments

Add a Comment