数组和对象被视为真值

var shoppingCart=['鞋','连衣裙','皮带'];
println(Boolean(shoppingCart));
 
var person={};//字面量创建对象
 
// 设置字面量对象属性
person.name='huangshiren';
person.age=58;
person.appetite=3;
person.eat=function(){
    document.write('正在吃饭');
}
 
println(Boolean(person));
 
function println(a){
    document.write(a+'<br>');
}

  

猜你喜欢

转载自www.cnblogs.com/max-hou/p/8926707.html
今日推荐