国产白浆流出一区二区-精品日韩欧美一区二区-亚洲欧美精品一区久久-久草精品在线播放视频

全國(guó)服務(wù)熱線:400-603-3310 廣州熱線:020-85201720   網(wǎng)站專線:020-85201717

專題中心 聯(lián)系我們

廣州網(wǎng)站建設(shè) 網(wǎng)站制作 網(wǎng)站設(shè)計(jì)公司 廣州騰虎網(wǎng)絡(luò)科技有限公司

WHAT'S NEW?

新聞動(dòng)態(tài)

致力提供國(guó)內(nèi)性價(jià)比高的建站資訊

當(dāng)前位置: > 騰虎新聞 > 網(wǎng)站優(yōu)化 >

java 代碼優(yōu)化

騰虎網(wǎng)絡(luò):2010-05-05  閱讀數(shù):  分享到:
一、字符串的連接
  通常我們進(jìn)行字符串連接是這樣的:
   var veryLongMessage =
  
‘This is a long string that due to our strict line length limit of’ +
  
maxCharsPerLine +
  
‘ characters per line must be wrapped. ‘ +
  
percentWhoDislike +
  
‘% of engineers dislike this rule. The line length limit is for ‘ +
  
‘ style purposes, but we don’t want it to have a performance impact.’ +
  
‘ So the question is how should we do the wrapping?’;
  

  可以用如下的數(shù)字代替:
   var veryLongMessage =
  
['This is a long string that due to our strict line length limit of',
  
maxCharsPerLine,
  
' characters per line must be wrapped. ',
  
percentWhoDislike,
  
'% of engineers dislike this rule. The line length limit is for ',
  
' style purposes, but we don't want it to have a performance impact.',
  
' So the question is how should we do the wrapping?'
  
].join();
  

  二、通過助手函數(shù)生成字符串
  
   通過把字符串生成器傳遞到函數(shù)中來構(gòu)造一個(gè)長(zhǎng)字符串,要避免臨時(shí)的String結(jié)果,例如,假設(shè)函數(shù)buildMenuItemHtml_ 需要用文字串(literal)和變量來構(gòu)造String,并在內(nèi)部使用了String構(gòu)造器.而不是如下方式使用:
  
var strBuilder = [];
  
for (var i = 0, length = menuItems.length; i

官方微信

公司地址:廣州市天河區(qū)福元南路4號(hào)達(dá)維商務(wù)中心2305
銷售熱線:020-85201720  85201717  或 400-603-3310

版權(quán)所有:廣州騰虎網(wǎng)絡(luò)科技有限公司
粵ICP備13073147號(hào) 

粵公網(wǎng)安備 44010602001101號(hào)