5

I've been noticing lately, as I've played around with javascript, HTML5, and node.js for the first times that javascript seems to be a language that is used very differently (and with different syntax) depending on where it is used at. My observation with javascript is this:

-Front end javascript finds the JS embedded in HTML5 pages, where it is used to build dynamic webpages and react to events that occur on the page.

-Back end JS is used as a solo language with node.js and its associated packages to handle web page requests, data transfers, and general server tasks.

Have I accurately summarized front end versus back end JS?

  • 2
    I think you just summarized front end versus back end, but nothing javascript-specific. Of course it is used differently for different purposes with different apis, but the syntax is the same. Or what differences in code patterns could you observe? – Bergi Mar 22 '14 at 16:18
  • I incorrectly stated what I had noticed. The syntax doesn't really change, it's the built in code that you can reference which changes. I was talking about the difference of when you are in the front end working with html pages vs being in the back end having access to node and its associated frameworks. – Max Mar 23 '14 at 23:34
0

That's a good summary.

Note that if you're front-loading functionality into your browser page, there may be little difference between your front-end and back-end javascript. For example, I worked on an app that did pathfinding through maps of airports. I did it in javascript in the browers to keep it fast & save a round trip. My code to do the graph traversal didn't make any reference to the browser or events, so it could have run on either front end or back end. I just put it on the front end to speed things up.

That's an addendum to your summary, though, rather than a contradiction.

4

That's generally correct, not just for Javascript but for any language. Javascript just happens to be the de facto language for doing such. You could use most any language for manipulation of page elements. This is what CGI is. Javascript just happens to "live" in the browser rather than on a server. This makes things like AJAX possible, which in turn makes the modern web as we know it possible.

The reason that Javascript appears different on the "front end" versus on the "back end" is that Javascript on the front end is tied to the DOM while Javascript on the backend doesn't need to be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.