/*
//:冒号的用法表示类的属性或者方法(与c#比较)
//{}新建对象
//var aa={a:{b}};//表示新建对象,并且设置对象的属性的值
//var aa={a:1};
//alert(aa.a);
alert(_.get({a:{b:{c:1}}},['a','b','c']));
*/
/*
//测试hash
//.has['a']['b']==>has.a.b
var has={a:{b:function(){alert('aaa');}},c:'ccc'};
var arr=['a','b'];
alert(typeof has['a']['b']);
alert(typeof has.a.b]);
*/
//动态给对象添加和删除属性、遍历对象的属性
if(_t in target)
{
return
}
else
{
try
{
target[_t] = 1;//给类添加属性
}
catch(e)
{
return
}
}
p = (p = target.constructor) ? p.prototype : _o;
for(i in target)//取出每一个对象的属性的名称,如果要取出属性的值则target[i]
{
if(i != _t)
{
if(l < n &&
target[i] &&
(typeof target[i] == "object" || typeof target[i] == "function"))
{
self(target[i],n,l)
}
if( ! (p && p[i]) &&
i != "prototype" &&
i != "constructor")
{
try
{
delete target[i]
}
catch(e){}
}
}
}
//举例:
a=
{
b:"b",
a:function()
{
alert('a');
},
c:{}
}
var p="___1_";
if(!(p in a))
{
a[p]="pppp";
}
if('b' in a)
{
//a[p]="pppp";
delete a[b];
}
for(i in a)
{
alert('key='+i+'\r\nvalue='+a[i]+'\r\ntype='+typeof(a[i])+'\r\nconstructor='+a[i].constructor);
}