jQuery in Action

Functions as first-class citizens
333
This sequence of alerts illustrates the following:
When the function is called directly as a top-level function, the function
context is the
window
instance
e
.
When called as a property of an object (
o1
in this case), the object becomes
the function context of the function invocation
f
. We could say that the
function acts as a method for that object--as in
OO
languages. But take care
not to get too blas about this analogy. You can be led astray if you're not
careful, as the remainder of this example's results will show.
Figure A.4
The object serving as the function
context changes with the manner
in which the function is called.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.