JavaScript Good Parts学习笔记-语法篇

JavaScript基础语法详解
本文详细介绍了JavaScript的基础语法,包括保留字、字符串表示方法、switch等流程控制语句的使用方式及注意事项、作用域规则、真假值判断标准以及类型判断函数typeof的使用等内容。

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.

转载于:https://www.cnblogs.com/sdfczyx/p/6396591.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值