Chrome inspector’s 0 variable

Ever noticed a little commented-out expression hanging off your code in Chrome’s inspector that looks something like ==$0?

Chrome Inspector 0 variable

Google Chrome’s inspector assigning the above line a variable of 0.

I have, but never gave it much mind. I finally thought I’d look into it today and wish I had a long time ago. Turns out what the expression means is that if you click on a line of code in the inspector or right click inspect an element the variable 0 gets assigned to that node and its children.

Calling this variable by typing $0 into the console of Chrome will then display just that node and its children. Super helpful if you’re like me and prefer to focus on certain lines or nodes without the clutter of everything else in the DOM.

Google Chrome console

By typing $0 into the console of the browser just the selected line of code in the inspector will display along with its children.

Pretty handy trick, right? Well, you can also use $1 $2 $3 $4 to go back and look at previous nodes that you inspected before the most current $0 inspection. Stack Overflow user deadlock, has the winning explanation here.

Tell Protractor where your Angular app lives, avoid sync issues

A handy trick (read: best practice) I ran into today was about how to properly inform Protractor where to look for your Angular application when it pols the DOM.

In my early Protractor tests I always started out with something like:

// ignore Angular and sync
beforeEach(function() {
    browser.ignoreSynchronization = true;

I have a few tests that need to run back and fourth between Angular and non-Angular pages and this worked in a pinch but I never really looked into the details of it.

Today while working on a new test that’s being extremely finicky, I needed to debug that line a bit and came across a great post by Vincent Tunru. In essence, adding a browser.ignoreSynchronization = true;  line to each test works, but in reality it’s better to simply tell protractor in your config file where your Angular app will exist and let it sort out whether or not there’s Angular on the page.

You can accomplish this by adding to your cons.js file the following:

exports.config = {
  rootElement: '*[ng-app]', 


Which will tell Protractor that your Angular app should be found on an element with the attribute of ng-app whether your Angular app is in the default body tag or most likely not.

Neat and much cleaner. Thanks, Vincent!