日韩欧美人妻无码精品白浆,夜夜嗨AV免费入口,国产欧美官网在线看,高校回应聋哑女生因长相完美被质疑

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

js基礎(chǔ):JavaScript的五個(gè)技巧

admin
2010年8月18日 10:21 本文熱度 4239
五條javascript技巧幫助你提高代碼質(zhì)量:
 1.只在<form>元素上使用submit事件
  綁定事件處理表單時(shí),使用表單得submit事件而不是click事件。
 2.如果可點(diǎn)擊,確認(rèn)是否是鏈接

 3.簡(jiǎn)單的for循環(huán)優(yōu)化
  下面是對(duì)for循環(huán)做的一個(gè)非常簡(jiǎn)單的改變,但是它確可以提高循環(huán)的效率

 

 

 for ( var i = 0; i < elements.length; ++i )
 for ( var i = 0, j = elements.length; i < j; ++i )


   第二行代碼中elements.length被存在變量j中,所以不必在每次循環(huán)的時(shí)候重復(fù)讀取它。

 
 4.事件處理時(shí)使用匿名函數(shù)(Use anonymous functions for event handlers)
  象下面這樣比較短的函數(shù)使用匿名函數(shù)比引用一個(gè)其他地方命名的函數(shù)可讀性要高

 

anchor.onclick = function() {
                    map.goToPosition( home );
                    return false;
                 }


 5.使用Array.join代替字符串連接(concatenating strings)

  遇到比較長(zhǎng)的字符串連接的時(shí)使用Array.join代替字符串連接可以獲得更好的效率而且可讀性更高。
 

 

 var text = 'There are' + elements.length + 'members in the       

         elements array.';
                var text = ['There are', elements.length, 'members in the

elements array.'].join(' ');


 注:關(guān)于最后一條好像還有爭(zhēng)議

 

On 12 Sep 07

Stuart Colville said:

I'd disagree with the last item on using Array.join for concatenating strings: Firstly, the only real benefit in using this approach is when you are concatenating a lot of strings together. With three strings it may also actually be slower due to the overhead of initialising the array.

Secondly the performance increase from using Array.join in the right situation is generally only seen in IE due to it's slow JavaScript engine which has not seen the same levels of optimisations that have been made in other browsers.

 

 

Update

A number of people have mentioned to me that the Array.join technique for string concatenation is a bad one, particularly if you're only doing it with a small number of strings. Our benchmarks show it being faster for IE when you get to about 6/7 string concatenations, so it's been useful to us in some situations. But I'd agree with Stuart below that for the average situation it's not going to be worth it. However, I don't see using Array.join() for string concatenation as an abuse of JavaScript.

該文章在 2010/8/18 10:21:51 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場(chǎng)、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場(chǎng)作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲(chǔ)管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved