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

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

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

廣州網(wǎng)站建設 網(wǎng)站制作 網(wǎng)站設計公司 廣州騰虎網(wǎng)絡科技有限公司

WHAT'S NEW?

新聞動態(tài)

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

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

java 代碼優(yōu)化

騰虎網(wǎng)絡:2010-05-05  閱讀數(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?’;
  

  可以用如下的數(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ù)中來構造一個長字符串,要避免臨時的String結果,例如,假設函數(shù)buildMenuItemHtml_ 需要用文字串(literal)和變量來構造String,并在內(nèi)部使用了String構造器.而不是如下方式使用:
  
var strBuilder = [];
  
for (var i = 0, length = menuItems.length; i

官方微信

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

版權所有:廣州騰虎網(wǎng)絡科技有限公司
粵ICP備13073147號 

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