Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

jslint_com · This group has moved to Google Plus.

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 583
  • Category: JavaScript
  • Founded: Mar 7, 2008
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Re: window (UNCLASSIFIED)   Topic List   < Prev Topic  |  Next Topic >
Summarize Messages | View Threaded Sort by Date v  
#2084 From: "Cheney, Edward A SSG RES USAR USARC" <austin.cheney@...>
Date: Wed Mar 30, 2011 2:35 pm
Subject: Re: [jslint] window (UNCLASSIFIED)
sandyhead25
Send Email Send Email
 
Classification: UNCLASSIFIED


On 03/29/11, Erik Eckhardt <erik@...> wrote:

> If you were creating a specialized code library, what method would you use
> to "namespace" all the functions in use by that library? Since functions are
> themselves globals, would you just create a single "master" object, itself
> global, with all other variables inside of it? Then, in commons use, either
> use this.fn() or libraryname.fn() all over the place instead of just fn()
> when you want to use a function? And something similar for any variables
> that are needed to control the operation of the code library (say it's a
> popup widget that needs to keep track of all the open popups and whether a
> particular popup template has been loaded via ajax or not)?
>

var o = { // global object
first: function (xyz) {
return xyz;
},
second: function (abc) {
return abc;
}
};

o.first(); // this executes the first function from above
o.second(); // this executes the second function from above

This works because the functions are members of a named object, therefore
the functions are references as object properties bound to the named object.

My suggestion is to never use this:
function nameof () {}

Instead always use either the form in the example or this form:
var asdf = function () {};

If this fails to answer your question please let me know.

Austin Cheney, CISSP
http://prettydiff.com/

Classification: UNCLASSIFIED



 
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help