注意FLASH AS2中的null、undefined、NaN、""

类别:编程语言 点击:0 评论:0 推荐:

FLASH中null、undefined、NaN、""这3个特殊的值是非常容易弄错的,不过大家可以从下面的语句中看出各自的区别:

var ddd0:String;

var ddd1:String = null;

var ddd2:String = undefined;

var ddd3:String = NaN;

var ddd4:String = "";

trace("ddd0="+ddd0);

//output:undefined

trace("ddd1="+ddd1);

//output:null

trace("ddd2="+ddd2);

//output:undefined

trace("ddd3="+ddd3);

//output:undefined

trace("ddd4="+ddd4);

//output:

var ddd5:String = "233.2";

trace("ddd0="+Number(ddd0));

//output:NaN

trace("ddd1="+Number(ddd1));

//output:NaN

trace("ddd2="+Number(ddd2));

//output:NaN

trace("ddd3="+Number(ddd3));

//output:NaN

trace("ddd4="+Number(ddd4));

//output:NaN

trace("ddd5="+Number(ddd5));

//output:233.2

本文地址:http://com.8s8s.com/it/it24521.htm