JavaScript Variable Performance

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    4 Favorites & 1 Group

    JavaScript Variable Performance - Presentation Transcript

    1. JavaS cript Variable Performance Nicholas C . Zakas P rincipal Front E nd E ngineer, Yahoo!
    2. S cope C hains
    3. When a Function E xecutes • An execution context is created • The context's scope chain is initialized with the members of the function's [[S cope]] collection • An activation object is created containing all local variables • The activation object is pushed to the front of the context's scope chain
    4. E xecution C ontext Identifier R es olution • S tart at scope chain position 0 • If not found go to position 1 • And so on
    5. Identifier R es olution • Local variables = fast! • The further into the chain, the slower the resolution
    6. Identifier R es olution (R eads ) Firefox 3 Firefox 3.1 Beta 2 Google Chrome 1 Internet Explorer 7 Time Internet Explorer 8 Beta 2 Opera 9.62 Safari 3.1 (525.13) Safari 3.2 (525.27.1) WebKit Nightly (528+) 1 2 3 4 5 6 Identifier Depth
    7. Identifier R es olution (Writes ) Firefox 3 Firefox 3.1 Beta 2 Google Chrome 1 Internet Explorer 7 Time Internet Explorer 8 Beta 2 Opera 9.62 Safari 3.1 (525.13) Safari 3.2 (525.27.1) WebKit Nightly (528+) 1 2 3 4 5 6 Identifier Depth
    8. R ecommendations • S tore local references to out-of-scope variables – E specially global variables • Avoid the with statement – Adds another object to the scope chain, so local function variables are now one step away
    9. E tcetera • M y blog: www.nczonline.net • M y email: nzakas@ yahoo-inc.com • Twitter: @ slicknet

    + Nicholas ZakasNicholas Zakas, 10 months ago

    custom

    2115 views, 4 favs, 0 embeds more stats

    My talk at the January 21, 2009 Mountain View JavaS more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2115
      • 2115 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 4
    • Downloads 57
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events