117

I'm just reading this documentation about Javascript 1.2, but I'm wondering which version of Javascript is being used in the most popular browsers.

http://www.tutorialspoint.com/javascript/javascript_nested_functions.htm

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Exitos
  • 29,230
  • 38
  • 123
  • 178

7 Answers7

99

Click on this link to see which version your BROWSER is using: http://jsfiddle.net/Ac6CT/

You should be able filter by using script tags to each JS version.

<script type="text/javascript">
  var jsver = 1.0;
</script>
<script language="Javascript1.1">
  jsver = 1.1;
</script>
<script language="Javascript1.2">
  jsver = 1.2;
</script>
<script language="Javascript1.3">
  jsver = 1.3;
</script>
<script language="Javascript1.4">
  jsver = 1.4;
</script>
<script language="Javascript1.5">
  jsver = 1.5;
</script>
<script language="Javascript1.6">
  jsver = 1.6;
</script>
<script language="Javascript1.7">
  jsver = 1.7;
</script>
<script language="Javascript1.8">
  jsver = 1.8;
</script>
<script language="Javascript1.9">
  jsver = 1.9;
</script>

<script type="text/javascript">
  alert(jsver);
</script>

My Chrome reports 1.7

Blatantly stolen from: http://javascript.about.com/library/bljver.htm

chris Frisina
  • 19,086
  • 22
  • 87
  • 167
Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
  • 6
    What about minor releases? e.g. 1.8.1, 1.8.2, 1.8.3...you see how this would get tedious. – Nick Craver Nov 24 '10 at 21:15
  • 12
    You would be better off using feature detection. – jwueller Nov 24 '10 at 21:16
  • I would assume 1.8 would run for all 1.8.x as the API wouldn't change in minor releases at all. But that's simply an educated guess about this works. – Alex Wayne Nov 24 '10 at 21:17
  • 2
    1.8.1 for example added native `JSON` support, 1.8.5 is up to ECMAScript 5 compliance...these are important milestones :) – Nick Craver Nov 24 '10 at 21:19
  • 4
    So this told me Chrome was 1.7, yet has native JSON support. Maybe the right answer to this question is more that the javascript version in a browser does not necessarily indicate very much useful information. – Alex Wayne Nov 25 '10 at 00:40
  • 1
    Mozilla support javascript up to version 1.8 but syntax is different: `````` – Yukulélé Mar 16 '14 at 20:27
  • 1
    Weird part about this script is that if I drop check for 1.7 i.e. comment out then it starts reporting 1.6 as JavaScript version, similarly if I drop check for 1.6 as well its starts reporting 1.5 as JavaScript version and so on and so forth. However, if I drop all but >= 1.8 it gives no output. Does it indicates that the current version is 1.7 and as compatible with all previous versions but not newer versions i.e. 1.8 and after? – sactiw May 20 '15 at 04:35
  • As of Date Sep 23, 2022, Chrome version - 105.0 : Says `1.5`, While the answer says `1.7`Which was given in 2010. Are we here missing something – Ravi Parekh Sep 23 '22 at 13:37
42

Wikipedia (or rather, the community on Wikipedia) keeps a pretty good up-to-date list here.

  • Most browsers are on 1.5 (though they have features of later versions)
  • Mozilla progresses with every dot release (they maintain the standard so that's not surprising)
  • Firefox 4 is on JavaScript 1.8.5
  • The other big off-the-beaten-path one is IE9 - it implements ECMAScript 5, but doesn't implement all the features of JavaScript 1.8.5 (not sure what they're calling this version of JScript, engine codenamed Chakra, yet).
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • 3
    Firefox 4 (JavaScript(TM) 1.8.5) and IE9 (JScript 9) implement a lot of *ECMAScript 5* features, but consider for example [JavaScript(TM) 1.8](https://developer.mozilla.org/en/JavaScript/New_in_JavaScript/1.8), is *full* of *non-standard* features, which aren't available on IE9 (and they are not part of the ES5 spec.), they are *Mozilla-extensions*. – Christian C. Salvadó Nov 24 '10 at 21:37
  • @CMS - excellent point on the bits it doesn't implement, tried to improve on the above given this has bubbled to the top. – Nick Craver Nov 24 '10 at 22:01
  • 2
    Thanks, IMO is important point to emphasize it that *JScript !== JavaScript(TM)* and that the Mozilla's JS version numbers are almost meaningless to other implementations... – Christian C. Salvadó Nov 24 '10 at 22:47
  • 1
    For what it's worth, it appears that Wikipedia's "pretty good up-to-date list" stopped being such around the time that this answer was provided. It doesn't appear to have been updated since ~2010... – NetXpert Dec 17 '18 at 20:20
19

In chrome you can find easily not only your JS version but also a flash version. All you need is to type chrome://version/ in a command line and you will get something like this:

enter image description here

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
  • 10
    ha ha! That is not JS version but the version number for the V8 Engine. Also, today, in 2015 they have moved to Blink as their engine of choice – Chris Roy May 18 '15 at 20:01
  • @ChristianM.Raymonds then why does my chrome v`46.0.2490.86` on November 2015 still shows `V8 4.6.85.31`? – Salvador Dali Nov 20 '15 at 22:24
  • @Savador Dali OP was asking about JS version - read JavaScript Language Version understood by the engine and not the version of the engine. Anything greater than Chrome 28 uses Blink. Please do your research. – Chris Roy Nov 21 '15 at 16:18
  • 1
    @SalvadorDali- That's the version of V8 engine(a Javascript engine) and NOT Javascript version. – nanosoft Oct 12 '16 at 14:17
  • 5
    @ChristianM.Raymonds - Blink and V8 are two very different things. V8 is JS engine and Blink is web engine and Chrome uses both. They are two separate Engines for two very different things and usage of one is not mutually exclusive of other in any way. – nanosoft Oct 12 '16 at 14:20
  • Is there a way in Firefox to display SpiderMonker version (there is nothing in about:support)? – noraj Jul 01 '22 at 09:19
6

Rather than finding which version you are using you can rephrase your question to "which version of ECMA script does my browser's JavaScript/JSscript engine conform to".

For IE :

alert(@_jscript_version);      //IE

Refer Squeegy's answer for non-IE versions :)

Robin Maben
  • 22,194
  • 16
  • 64
  • 99
  • 4
    Did Squeegy change user names or delete his/her answer? There are no answers here from a user named Squeegy. – Peter Hansen Apr 03 '15 at 18:28
  • @PeterHansen: Oops, should have linked to the answer :) – Robin Maben Apr 06 '15 at 05:54
  • and browsers do that only partially, you may find 97% of ES6, 39% of ES7, http://kangax.github.io/compat-table/es6/, and even these tables are not quite true. – prosti Dec 04 '16 at 21:59
  • This only works if `Conditional Compilation` is turned On, so may not work 100% if you have SysAdmin that believe in "bread-crumb" security – GoldBishop Nov 29 '17 at 21:08
1

All of todays browsers use at least version 1.5:
http://en.wikipedia.org/wiki/ECMAScript#Dialect

Concerning your tutorial site, the information there seems to be extremely outdated, I beg you to head over to MDC and read their Guide:
https://developer.mozilla.org/en/JavaScript/Guide

You may still want to watch out for features which require version 1.6 or above, as this might give Internet Explorer some troubles.

Ivo Wetzel
  • 46,459
  • 16
  • 98
  • 112
0

JavaScript 1.2 was introduced with Netscape Navigator 4 in 1997. That version number only ever had significance for Netscape browsers. For example, Microsoft's implementation (as used in Internet Explorer) is called JScript, and has its own version numbering which bears no relation to Netscape's numbering.

NickFitz
  • 34,537
  • 8
  • 43
  • 40
0

I decided to write a script based on the previous answers that gives you the language version inside the browser via binary search. Probably not useful but answers the question.


window.version=[0,0,0,0];

void async function main(){

let currentVersion = await loadVersion();
console.log(currentVersion);

}();


function tryVersion(num,i){
    
    if(i==0){
        
        return tryFirstVersion(num);
        
    }
    if(i==1){
        
        return trySecondVersion(num);
        
    }
    if(i==2){
        
        return tryThirdVersion(num);
        
    }
    if(i==3){
        
        return tryFourthVersion(num);
        
    }
    
    
}

function tryFirstVersion(num) {
    
    
    return new Promise(function (resolve, reject) {
        var s;
        
        s = document.createElement('script');
        s.innerHTML = 'window.version[0]='+num+';document.currentScript.onload();';
        s.setAttribute('language','Javascript'+num+'.0');
        s.onload = resolve;
        document.head.appendChild(s);
        var follow = document.createElement('script');
        follow.innerHTML = 'document.currentScript.onload();';
        follow.onload = resolve;
        document.head.appendChild(follow);
    });
}

function trySecondVersion(num) {
    
    
    return new Promise(function (resolve, reject) {
        var s;
        
        s = document.createElement('script');
        s.innerHTML = 'window.version[1]='+num+';document.currentScript.onload();';
        s.setAttribute('language','Javascript'+version[0]+'.'+num);
        s.onload = resolve;
        document.head.appendChild(s);
        var follow = document.createElement('script');
        follow.innerHTML = 'document.currentScript.onload();';
        follow.onload = resolve;
        document.head.appendChild(follow);
    });
}

function tryThirdVersion(num) {
    
    
    return new Promise(function (resolve, reject) {
        var s;
        
        s = document.createElement('script');
        s.innerHTML = 'window.version[2]='+num+';document.currentScript.onload();';
        s.setAttribute('language','Javascript'+version[0]+'.'+version[1]+'.'+num);
        s.onload = resolve;
        document.head.appendChild(s);
        var follow = document.createElement('script');
        follow.innerHTML = 'document.currentScript.onload();';
        follow.onload = resolve;
        document.head.appendChild(follow);
    });
}

function tryFourthVersion(num) {
    
    
    return new Promise(function (resolve, reject) {
        var s;
        
        s = document.createElement('script');
        s.innerHTML = 'window.version[3]='+num+';document.currentScript.onload();';
        s.setAttribute('language','Javascript'+version[0]+'.'+version[1]+'.'+version[2]+'.'+num);
        s.onload = resolve;
        document.head.appendChild(s);
        var follow = document.createElement('script');
        follow.innerHTML = 'document.currentScript.onload();';
        follow.onload = resolve;
        document.head.appendChild(follow);
    });
}

async function getVersion(i){
    


let upperLimit = 0;
let nextVersion = 0;
let doubling = true;
while(doubling){
nextVersion = version[i];
if(nextVersion==0){nextVersion=1;}else{nextVersion=nextVersion*2;}

await tryVersion(nextVersion,i);

    if(nextVersion > version[i]){
    
        upperLimit = nextVersion;
        doubling = false;
    
    }
}

let halving = true;
while(halving){
    
    if(upperLimit<=(version[i]+1)){
        halving=false;
    }
    nextVersion = Math.floor((version[i] + upperLimit)/2);
    await tryVersion(nextVersion,i);    
    if(nextVersion > version[i]){
        upperLimit = nextVersion;
    }
    
}

return version[i];
    
    
}


async function loadVersion(){

await getVersion(0);
await getVersion(1);
await getVersion(2);
await getVersion(3);
return version;

}