jQuery in Action

338
APPENDIX
JavaScript that you need to know but might not!
as an object, but it's an important concept to grasp when writing JavaScript of even
moderate complexity.
Functions in JavaScript are first-class citizens that can be declared and refer-
enced in a manner similar to the other object types. We can declare them using
literal notation, store them in variables and object properties, and even pass them
to other functions as parameters to serve as callback functions.
The term function context describes the object that's referenced by the
this
pointer during the invocation of a function. Although a function can be made to
act like a method of an object by setting the object as the function context, func-
tions aren't declared as methods of any single object. The manner of invocation
(possibly explicitly controlled by the caller) determines the function context of
the invocation.
Finally, we saw how a function declaration and its environment form a closure
allowing the function, when later invoked, to access those local variables that
become part of the closure.
With these concepts firmly under our belts, we're ready to face the challenges
that confront us when writing effective JavaScript using jQuery on our pages.


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

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