87,907
社区成员
发帖
与我相关
我的任务
分享
function getStyle( elem, name ) {
if (elem.style[name])
return elem.style[name];
else if (elem.currentStyle)
return elem.currentStyle[name];
else if (document.defaultView && document.defaultView.getComputedStyle) {
name = name.replace(/([A-Z])/g,"-$1");
name = name.toLowerCase();
var s = document.defaultView.getComputedStyle(elem,"");
return s && s.getPropertyValue(name);
} else
return null;
}
function getStyle(elem,name){
if(elem.style[name]){
return elem.style[name];
}else if(elem.currentStyle){
return elem.currentStyle[name];
}else if(document.defaultView && document.defaultView.getComputedStyle){
name = name.replace(/([A-Z])/g,"-$1");
name = name.toLowerCase();
var s = document.defaultView.getComputedStyle(elem,"");
return s && s.getPropertyValue(name);
}else{
return null;
}
}
function func() {
this.hello=function () {alert("hello");};
this.a="testing";
}
var a = new func();
function returnValue() {
this.v="v";
var i=10;
return this.p && a.a;
}
alert(returnValue());
上面会提示undefined 。
正确的理解是,return a&&b 表示返回值:如果a存在值(不是null,undefined,0,false etc),会返回b的值,否则,会返回一个unfefined (null,false之类)