在angularJs应用程序中,我检查变量是否未定义,调用window.innerHeight只发生一次。 有人告诉我改变这个:
if(typeof inner_height === 'undefined'){
inner_height = window.innerHeight;
console.log('innesr_height was undefined, now '+inner_height);
}
var h_val = calcPixels(inner_height, valueInPersent)
console.log('h_val is '+h_val);
return h_val;
到此:
return (h_val)?h_hval:h_hval = window.innerHeight;
是速记语法快得多吗?