• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
scope or not?
 

scope or not?

on

  • 1,114 views

CC-BY-SA Eric Bréchemier...

CC-BY-SA Eric Bréchemier
https://github.com/eric-brechemier/scopeornot-presentation

Presentation of the scopeornot library at ParisJS on December 21st, 2011.

Quoting the README of the scopeornot library:

"This project defines a single function scope() with multiple implementations. The goal is to make definition of modules and private scopes slightly simpler than using JavaScript Module pattern, and flexible enough to switch from static to dynamic module loading. You can choose one of the provided scope() implementations, replace it with another, tweak it to your needs, or create your own."

scopeornot on GitHub:
https://github.com/eric-brechemier/scopeornot

Statistics

Views

Total Views
1,114
Views on SlideShare
1,108
Embed Views
6

Actions

Likes
2
Downloads
1
Comments
0

3 Embeds 6

http://www.thelibrarynews.com 4
http://www.linkedin.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    scope or not? scope or not? Presentation Transcript

    • scope or not? ParisJS, December 21 st 2011
    • JavaScript Module Pattern
    • ( function(){ // a module } () ) ;
    • = Immediately-Invoked Function Expressions
        Ben Alman http://benalman.com/news/2010/11 /immediately-invoked-function-expression/
    • ( function(){ // private scope var id = "abc123"; function logout (){ location = "/logout?"+id; } } () ) ;
    • /*global APP:true, window */ var APP = APP || {}; APP.session = APP.session || ( function(window,user){ // Public API return { logout: function(){ window.location = "/logout?"+user.id(); } }; } (window,APP.user) ) ;
    • github.com/eric-brechemier / scopeornot
    • scope ( function(){ // a module } ) ;
    • scope ( function( context ){ // private scope var id = "abc123"; function logout (){ location = "/logout?"+id; } } ) ;
    • /*global scope */ scope( function(context){ // Declare aliases var window = context. window , user = context[" APP.user "]; // Public API return { logout: function(){ window.location = "/logout?"+user.id(); } }; }, [" window "," APP.user "], " APP.session " ) ;
    • THANK YOU!
    • Credits & Further Reading
      • Slide Template
        • Adapted from "tokyo-midtown-1.otp" CC-BY-SA Chih-Hao Tsai
      • JavaScript Module Pattern: In-Depth
      • JavaScript Scoping and Hoisting
        • by Ben Cheery
      • Unnecessarily comprehensive look into a rather insignificant issue of global objects creation
        • by kangax
      https://github.com/eric-brechemier/scopeornot-presentation