文档介绍:chapter 8
2012-7-29
Javascript: The Definitive Guide
Defining Functions
two ways to define a function
function definition expression
function declaration statement
difference between the above two methods
Invoking Functions
JavaScript functions can be invoked in four ways:
as functions
as methods
as constructors
indirectly through their call() and apply() methods
Method Chaining
When you write a method that does not have a return value of its own, consider having the method return this. If you do this consistently throughout your API, you will enable a style of programming known as method chaining in which an object can be named once and then multiple methods can be invoked on it:
(100).setY(100).setSize(50).setOutline("red").setFill("blue").draw();