I have the following script from http://javascript.about.com/library/bljver.htm
<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 type="text/javascript">
document.write('<p><b>Javascript version ' + jsver + ' supported<\/b><\/p>');
</script>
but wonder if there is a shorter way?
Looking at the comment you made to @meder, I would highly recommend you to go for feature detection, for example, to detect if the
indexOfmethod is available on Array objects:The JavaScript (TM) version numbers refer to the Mozilla implementation of the ECMAScript Standard.
In the early years, when the
languageattribute was widely used, you could for example specify"JavaScript1.2"to place code that was written for ECMAScript 2, but I wouldn’t recommend you this approach nowadays.The only reason you might want to specify a JavaScript(TM) version, is because you really need to use a Mozilla-specific extension, for example the
letkeyword, generators, iterators, expression closures, etc…See also: