是javascript速记如果更快?

时间:2014-06-24 17:37:40

标签: javascript optimization

在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;

是速记语法快得多吗?

0 个答案:

没有答案
相关问题