Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript, a couple more questions

Tags:

javascript

This is a bit of a round up of the things I haven't found clear answers to today.

  1. There appear to be different versions of Javascript, but I've not seen any books or web sites say "This targets ECMAScript version 2". There seems to be an ECMAScript 5 which if the wiki page is to be believed isn't used in any browsers. So do I need to know about versions?

  2. Server side Javascript. I've seen a few mentions of this, and I haven't been looking at it specifically, but in a sentence or two, where is server side Javascript used and why?

  3. I assume different browsers support different subsets (guessing) of Javascript, but then again, I haven't read that, it just seemed logical given the state of all the other web technologies. Is that right or am I way off?

like image 639
Ian Avatar asked Apr 10 '11 19:04

Ian


1 Answers

1: ECMAScript 3 is what all current browsers support.. ES5 is the new standard that is being adopted at the moment.

But this does not keep you from using most of ES5 features in todays browers. Turns out you can emulate most of them by adding functions to prototypes (like the string.trim function is rather easy to implement)

Update: As Reid pointed out in the comments there is a nice table outlining ES5 compatibility in different browsers available here

2: Node.js seems to be the most popular server-side high-scale javascript engine at the moment, but there are a lot of them.

There are a couple other servers that also run javascript on the server. MongoDB for example uses JSon to transfer results back and forth, and map/reduce functions have to be written in JavaScript that then gets run on the server.

3: No, they all support the ES3 standard. They only differ in API (the language is the same).

This means that while Google Chrome supports local storage, they provide access to that functionality through JavaScript objects inside the DOM. In IE8 these objects simply don't exist and can't be called.

Also: EcmaScript always refers to JavaScript, they just couldn't name the standard JavaScript since JavaScript is a trademark of Sun (the company that owns Java).

like image 152
Tigraine Avatar answered Oct 23 '22 12:10

Tigraine