Javascript: How to check and retrieve the Javascript version of the Browser

With Javascript's rapid evolution, especially Array comprehensions and generators (Pythonian yield!) in Javascript version 1.7, I was looking into an option to report the javascript version of the Browser.
My interest was piqued since apparently those Javascript additions are not yet available in Google's Chrome.

Besides many dated scripts which link the Browser navigator information to a javscript version, I found this  interesting way of using script <script>-elements specified with incremental language attributes. Within it, one simply defines the javascript version. If the script element is specified above the own Javascript version, it is ignored:

<script language=”Javascript1.5″>jsver = 1.5;</script>


It turns out Chrome v15 should implement JS version 1.7 according to my script, and actually support array comprehensions.

To quickly  retrieve the javascript version of your browser, I wrote the following script. Feel free to copy and paste it if you require. The js-version will then be written to the javascript console .


<script type="text/javascript">// <![CDATA[
//put this code in your respective onload function

//this array is a good example for the need of a
//pythonian range function which I wrote.
var _jsVer, _jsVs = [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0];
for(i=0; i<_jsVs.length; i++){
document.write("<script language='Javascript"+_jsVs[i]+"'>_jsVer = "+_jsVs[i]+";<\/script>");
}
console.log("your javascript version is: %s", _jsVer);
//]]
</script>
LihatTutupKomentar