Optimizing JavaScript Code – 1

There is an excellent article named Optimizing JavaScript Code. The authors are software engineers on Gmailand Google chrome.I appreciate the knowledge described in this article and try to repeat it in myown words.Faster string concatenationI have

JavaScript tips and tricks – 1

Produce boolean value from other typesAll objects in JavaScript can be converted to boolean implicitly, look at these examples:0 == false; // true1 == true; // true'' == false // truenull == false // truebut these values are not the type of

Observer pattern in JavaScript

The observer pattern (a subset of the asynchronouspublish/subscribepattern) is a softwaredesign pattern in which an object,called the subject, maintains a list of its dependents, called observers, andnotifies them automatically of any state changes,

JavaScript tips and tricks – 2

Always specify the second argument - parseIntparseInt converts a string to an int number, the syntax is:parseInt(str, [radix])The second argument is optional, which specify the radix of the first argument.If you omit radix, following the

JavaScript tips and tricks – 3

Is undefined a reserved wordIt seems like so, but actually it doesn’t.var undefined = 'Hello'; undefined; // 'Hello'This may surprise you, but it does work well. undefined is just a pre-defined variable.Note: Never assign a value to undefined,

AOP in JavaScript

AOP stands for Aspect-oriented programming. I think the main point of this technology is the ability to add code before or after a function execution.After some digging on the internet, i write my implement of AOP in JavaScript.1. First, see the

用javascript判斷視窗關閉事件

function window.onbeforeunload(){if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey||event.ctrlKey){     //判斷event.altKey是為了Alt+F4關閉的情況;判斷event.ctrlKey是為了Ctrl+W關閉的情況    

很牛的javascript日期轉換函式

 /*將String類型解析為Date類型.     parseDate('2006-1-1') return new Date(2006,0,1)     parseDate(' 2006-1-1 ') return new Date(2006,0,1)     parseDate('2006-1-1 15:14:16') return new Date(2006,0,1,15,14,16)     parseDate(' 2006-1-1 15:14:16 ') return new Dat

Regular Expression in JavaScript

Regular Expression are very important in professional JavaScript.There is a wonderful resource in Mozilla developer center.Two ways to construct a regular expression 1. Literal expression re = /ab+c/g; 2. Constructor function re = new

JavaScript tips and tricks – 4

JavaScript doesn’t have block scopeBlock doesn’t have scope in javascript, only function has scope.for(var i = 0; i < 2; i ++) { } i; // 2If you want to create scope, use anonymous function:(function (){   for(var i = 0; i < 2; i ++) {   }

JavaScript tips and tricks – 5

Fast string concatenationWe always use + to concatenate small strings into a large one, which is considered to be a good practice.But there will be a major hit on performance if you do many string concatenation operations on IE browser.Consider

[翻譯]JavaScript秘密花園 – Object, Prototype

文章目錄 關於作者(The authors)貢獻者(Contributors)許可(License)中文翻譯(Chinese Translation)對象作為資料類型(Objects as a data type)訪問屬性(Accessing properties)刪除屬性(Deleting properties)屬性名稱的文法(Notation of keys)屬性尋找(Property lookup)原型屬性(The prototype

Javascript中建立字串的new文法和literal文法

在Javascript中聲明一個字串,我們可以方便的使用literal(字面)文法:var str1 = 'Hello Javascript!';var str2 = "Hello World!"; 由於在Javascript中,任何事物都是對象,所以我們也可以使用new文法建立:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->var str3 = 

Confused with JavaScript prototype

They are two similar code below:1.<code>function User(name) {this.name = name;}User.prototype = { 'sex': 'man' };var user = new User('Zhang');alert(User.prototype['sex']);   // manalert(user.constructor.prototype['sex']);   //

Javascript實現表格的全選框

這是一個老生常談的問題了,不過還是拿我的解決辦法來晒晒太陽。最開始我是為Table中的每一項添加屬性 class="item1" 的方式實現的1. 第一種解決方案<table border="1" cellpadding="3" cellspacing="0">    <tr>        <th>            <input type="checkbox" onclick="checkAll(this, 'item1');" />   

Javascript中的範圍(scope)

類 C 語言一般都用於塊級範圍,但是Javascript中的 while, if-else, for, switch-case 等控制結構不具有自己的範圍,在Javascript中只有函數(function)具有自己的範圍,請比較如下的 C# 代碼和 Javascript 代碼:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->// C# 中 for 

Javascript限制多行文本輸入框的字元數

對於單行文字框,我們可以通過設定屬性maxlength來限制可輸入的最多字元數:<input type="text" maxlength="5" />對於多行文字框,如果想限制最多可輸入字元數,必須使用Javascript指令碼來達到目的。 1.

Javascript中的事件冒泡

這是一個基礎性的文章,使用Javascript觀察DOM中的事件冒泡機制,並介紹如何阻止預設行為和如何組織事件冒泡的方法。1. 第一個例子可以在Firefox下運行Code highlighting produced by Actipro CodeHighlighter

[原創]如何確保JavaScript的執行順序 – 之jQuery.html深度分析

上一篇:[原創]如何確保JavaScript的執行順序 – 之實戰篇1.      引言在上一篇文章《如何確保JavaScript的執行順序 - 之實戰篇》中,我們發現jQuery的html函數能夠確保動態載入的JavaScript按照引入順序執行。 我們先來簡單回顧下HTML原始碼(test2.htm):<html><head>    <title></title>    <script src="js/jquery-1.4.4.js"

[原創]如何確保JavaScript的執行順序 –之jQuery1.5.1與jQuery1.4.4的差異

1.      引言在上一篇文章《如何確保JavaScript的執行順序 -

總頁數: 3271 1 .... 330 331 332 333 334 .... 3271 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.