how js code running in sublime code example

Example 1: run javascript in sublime

Create JavaScript build system in Sublime Text #
Every built system is described on JSON file with .sublime-build extension. 
To create new one go to Tools > Build System > New Build System… 
If you are mac OS user, copy and paste this bit of code:
!!! Remember to save the file as   filename.sublime-build

{
  "cmd": ["/usr/local/bin/node", "$file"],
  "selector": "source.js"
}

If you are window user, copy and paste this bit of code: 
{
  "cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
  "selector": "source.js"
}

Example 2: run javascript sublime text 3

{
  "cmd": ["/usr/local/bin/node", "$file"],
  "selector": "source.js"
}