JavaScript Good Parts學習筆記-文法篇

來源:互聯網
上載者:User

標籤:cts   define   try   wro   optional   sar   instead   ase   debugger   

1 保留字一覽

 abstract
boolean break byte
case catch char class const continue
debugger default delete do double

else enum export extends
false final finally float for function
goto
if implements import in instanceof int interface
long
native new null
package private protected public
return
short static super switch synchronized
this throw throws transient true try typeof
var volatile void
while with

 

2

字串可以用單引號,也可以用雙引號。所有的字元都是16位的。

 

The switch, while, for, and do statements are allowed to have an optional label prefix
that interacts with the break statement.

JavaScript的代碼塊不像其他語言一樣,建立新的範圍。 因此變數應該定義在函數的頭部。

 

4

Here are the falsy values:
? false
? null

? undefined
? The empty string ‘‘
? The number 0
? The number NaN
All other values are truthy, including true, the string ‘false‘, and all objects.

 

5???原型鏈???(prototype chain)

The other form (called for in) enumerates the property names (or keys) of an object.
On each iteration, another property name string from the object is assigned to the
variable.
It is usually necessary to test object.hasOwnProperty(variable) to determine whether
the property name is truly a member of the object or was found instead on the prototype
chain.
for (myvar in obj) {
if (obj.hasOwnProperty(myvar)) {
...
}
}

6

不允許在return關鍵字和運算式之間換行。

不允許在break關鍵字和運算式之間換行。

 

7

 

The values produced by typeof are ‘number‘, ‘string‘, ‘boolean‘, ‘undefined‘,
‘function‘, and ‘object‘. If the operand is an array or null, then the result is
‘object‘, which is wrong.

JavaScript Good Parts學習筆記-文法篇

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.