Read OO JS

Most values convert to true with the exception of the following (which convert to false):
[b]
1. The empty string ""
2. null
3. undefined
4. The number 0
5. The number NaN
6. The boolean false
[/b]
These six values are sometimes referred to as being falsy, while all others are truthy

[b]This example also shows another interesting behavior—if JavaScript encounters a non-boolean expression as an operand in a logical operation, the non-boolean is returned as a result.[/b]

>>> true || "something"
true
>>> true && "something"
"something"

[b]Deleting Elements[/b]
In order to delete an element, you can use the delete operator. It doesn't actually remove the element, but sets its value to undefined. After the deletion, the length of the array does not change.

>>> var a = [1, 2, 3];
>>> delete a[1];
true
>>> a
[1, undefined, 3]


Understanding these topics will provide a solid base that will allow you to dive
into the second part of the chapter, which shows some interesting applications
of functions:
[list]
[*]Using anonymous functions
[*]Callbacks
[*]Self-invoking functions
[*]Inner functions (functions defined inside functions)
[*]Functions that return functions
[*]Functions that redefine themselves
[*]Closures
[/list]


[b]Function[/b]

1.Using argument


function sumOnSteroids() {
var i, res = 0;
var number_of_params = arguments.length;
for (i = 0; i < number_of_params; i++) {
res += arguments[i];
}
return res;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值