3

I have been developing in Node.js for some time now. Today, I came across this article Introduction to the JavaScript shell - Mozilla | MDN

It talks about javascript shell and goes onto say that it can execute javascript programs from a file as well.

I was able to research and understand V8 and spydermonkey.

I want to know the difference between Node.js and the javascript shell talked about in this article since it says that the shell can execute javascript programs on its own.

Do they only differ in that the node.js uses a V8 engine while the other uses a spidermonkey?

if so then why is it that node.js is so popularly used for writing Server Side JavaScript?

I couldn't exactly find what I was looking for on the Internet. either google showed me difference between spidermonkey and v8 or some forums on "difference between javascript and node.js" and since I am a new developer its really hard for me to understand,

Can spidermonkey be used to achieve the same?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Ashwin K Joseph
  • 371
  • 2
  • 4
  • 14
  • "Can spidermonkey be used to achieve the same?" Yes: https://github.com/mozilla/spidernode – str Jun 26 '17 at 19:04

2 Answers2

22

JavaScript is a language. node.js is not a language or a special dialect of JavaScript - it's just a thingamabob that runs normal JavaScript.

All browsers have JavaScript engines that run the JavaScript of web pages. Firefox has an engine called Spidermonkey, Safari has JavaScriptCore, and Chrome has an engine called V8.

Node.js is simply the V8 engine bundled with some libraries to do I/O and networking, so that you can use JavaScript outside of the browser, to create shell scripts, backend services or run on hardware (https://tessel.io/).

Credits : https://www.quora.com/What-is-the-difference-between-JavaScript-and-Node-js

I hope that helped clearing out the basic difference between them. The specifics you required are not answered here.

Darshit Pandit
  • 237
  • 3
  • 3
2

Node.js enables JavaScript to be used for server-side scripting, and runs scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.

Source: https://en.wikipedia.org/wiki/Node.js

Obviously the shell can not serve HTML web pages by itself.

In addition, Node.js is asynchronous, and non-blocking, meaning it can serve multiple requests and host multiple processes simultaneously.

EDIT: provided source.

frozen
  • 2,114
  • 14
  • 33
  • nodejs does this by requiring the http right? so, cant a module similar to it be written, if not the same module, for the javascript shell? wouldnt it be able to listen to http requests then? – Ashwin K Joseph Jun 26 '17 at 19:16
  • 1
    Node.js is a framework. The javascript shell is an execution environment. The execution environment can execute any javascript, including Node.js programs. – frozen Jun 26 '17 at 19:18
  • So i guess we can put it as node.js provides a runtime environment to run js files just as js shell does but along with it, it also provides extra libraries for i/o and expands the capabilities of the language. and nodejs implements the runtime by using the V8 engine – Ashwin K Joseph Jun 26 '17 at 19:23