Sebastian K
Sebastian K

Reputation: 6373

Is there a way to check which JavaScript version browser supports?

I am playing with some newer features of JavaScript such as Array.forEach (v.1.6).

I understand that in live code we should use feature detection, as explained here: To tell Javascript version of your browser So, basically something like:

typeof Array.prototype.forEach == 'function'

However, is there some way (e.g. website) , that shows which version of JavaScript is supported by different browsers? I basically want to check if a given version is already widely adopted by browsers or not.

Somethin like this for JavaScript support would be exactly what I am looking for.

Upvotes: 0

Views: 3341

Answers (2)

Matt
Matt

Reputation: 1558

I agree with the other comments that you should probably not check the javascript version as a way to make sure features you are using will work.

Recommended:

Not recommended:

However, to answer the question. Here is how you can check the version of javascript supported by the browser.

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

<p id="version"></p>

<script>
document.getElementById("version").innerHTML = version;
</script>

Upvotes: 1

Paul Mendoza
Paul Mendoza

Reputation: 5787

No, not really. You should do feature testing instead of which version of JS a browser supports for many of the new HTML5 features.

For some of the new features of ECMAScript 5 you can create or use third party shims that emulate the features and don't cause errors in older browsers. Not all features will work though for ECMAScript 5 but many will.

https://github.com/kriskowal/es5-shim

Upvotes: 3

Related Questions