Closed GoogleCodeExporter closed 9 years ago
但要是改的话如何判断x对象中是否包含有key1这个键,处理起
来是不是很麻烦!
Original comment by songjie8...@gmail.com
on 20 Aug 2009 at 8:58
var x:Object = new Object();
var y:Object = new Object();
x["a"] = null;
x["b"] = null;
y["a"] = undefined;
trace(x["a"]);
trace(x["b"]);
trace(y["a"]);
trace(y["b"]);
trace(x["a"] == y["a"]);
trace(x["a"] === y["a"]);
======RESULT======>>>
null
null
undefined
undefined
true
false
比较操作符===代表的是值与类型比较,就是说,左右两个参��
�比较的内容,不光需要值一样,类型也必须一样,而操
作符==仅仅是对值的比较
如果你对一个Map中的元素个数不关心的话,没必要引入外部��
�Map类,即便有要求可以自己写个简单的,
MyMap["size"] =
0;每次新增或删除一个元素的时候MyMap["size"]++或MyMap["size"]--
x["a"] = null; // 新增属性
x["b"] = undefined; // 删除一个存在的属性
if (x["b"] === undefined) { .. } // 判读属性不存在 ===
if (x["b"]) { .. } //
只要x["b"]的内容为null或undefined,if语句就会把值转换成false
这套理论适用于JavaScript
Original comment by rcom10002
on 20 Aug 2009 at 9:26
null代表你所引用的变量或属性什么的存在,但它所指向的值�
��不存在的
undefined意味着你所引用的变量或属性根本没在当前程序关联��
�中定义
Java中
String[] strings = new String[1];
string[0]; // null, a defined element with no values specified
string[1]; // undefined and an exception will be thrown
Original comment by rcom10002
on 20 Aug 2009 at 9:30
http://www.flashinsider.com/2005/07/25/null-equals-undefined-but-null-doesn-t-st
rictly-
equal-undefined/
Original comment by rcom10002
on 20 Aug 2009 at 9:33
已经删除了,改成你提供的这种方法,已测试没问题
Original comment by songjie8...@gmail.com
on 21 Aug 2009 at 5:26
Original issue reported on code.google.com by
rcom10002
on 19 Aug 2009 at 1:39