Wednesday, October 1, 2008

Difference between javascript 1.2 and 1.3

Javascript 1.3 added two new objects:

Object object
Function object

Different Behavior with Condition
In following code, javascript 1.3 and 1.2 produce different result.


var a = new Boolean(false);
if(a){
alert('the message is' + a);
}

javascript 1.3 treates a as true instead of false which 1.2 does. javascript check if the expression result is null or undefined, if not it treat it as true.




<script language='javascript'&lgt;

By default, it uses javascript 1.3 with common used browsers. To use 1.2, you will need to explicitely specify javasctipt 1.2

<script language='javascript 1.2'&lgt;

No comments: