Read OO JS
Most values convert to true with the exception of the following (which convert to false): **
- The empty string ""
- null
- undefined
- The number 0
- The number NaN
- The boolean false ** These six values are sometimes referred to as being falsy, while all others are truthy
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.
true || "something" true true && "something" "something"
Deleting Elements 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 = ; delete a; true a
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:
Using anonymous functions Callbacks Self-invoking functions Inner functions (functions defined inside functions) Functions that return functions Functions that redefine themselves Closures
Function
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;
}