You can also use phantomjs
Download phantomjs depending on the system (my case is Max OSX) from phantomjs.org
.You should put the path to phantomjs installation folder on the top of your javascript file. eg. #!./bin/phantomjs
Save your code. Go to the terminal where your javascript is saved and you can run using > phantomjs filename.js