Reputation: 833
I am learning javascript and other things used with it. I have read some links that talk about nodejs and underscore.js but I don't understand how they are related. I am not sure if they are related or not in the first place. I understand that underscore.js requires node.js to be pre installed. If underscore.js is a library then what is node.js? And what is the purpose of node.js. I am sorry if this is a stupid question. I am a beginner.
Upvotes: 1
Views: 100
Reputation: 760
Let's take a step back.
JavaScript is a programming language.
You probably know it's used in the browser. Node.js takes JavaScript and makes it so you can create JavaScript programs on your computer.
Now, underscore.js is a JavaScript library which provides lots of nice capabilities to JavaScript. Not necessarily on the computer/server in Node.js, but perhaps in the browser. But wherever you add it, it adds those features.
So there you have it. Both are JavaScript. There are related only by that.
Upvotes: 0
Reputation: 262504
They are not really related (except that both are Javascript technologies).
underscore.js is a Javascript library, like jQuery. It provides frequently used functions for use in your Javascript code.
node.js is a Javascript engine, a program that is used to run Javascript. Just like you have programs to run Perl, Ruby or Python code. In the Javascript world, this is a bit unusual, as traditionally, you would not write "server-side" programs in Javascript. Instead, the Javascript would run in a web browser, as part of a web site. The code that produces the web site on the server would be written in Java, Perl, Python, Ruby or whatever. With node.js, you can have the "whole stack" in the same language.
underscore.js does not require node.js.
In the browser, you can simply load underscore.js. If you have a server-side program, it may be running on node.js, but it could also use other engines, and underscore.js does not care.
node.js is also used as the basis for "build tools" in the Javascript world (similar to "make" for C people, or Maven for Java folks). Those are programs that a library developer uses to package the code, generate documentation, run unit tests, etc. Maybe underscore.js uses node.js to build itself.
Upvotes: 6