javascript str.length是在每次调用时还是一次调用时计算出来的?

问题描述

| 哪种方法更有效?有区别吗? 这个:
var str = \'abc\';

if(str.length == 20) {
    //...
}

if(str.length == 25) {
    //...
}

// and so on
或者这个:
var str = \'abc\';
var length = str.length;

if(length == 20) {
    //...
}

if(length == 25) {
    //...
}

// and so on
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)