so is namespace faking bad ? On Sat, May 30, 2009 at 4:19 PM, Ricardo <ricardob...@gmail.com> wrote:
> > Because you're creating a global variable, and global vars are evil :) > Same reason why you don't want to pollute the jQuery namespace. > > On May 30, 1:27 am, MorningZ <morni...@gmail.com> wrote: > > "If i make a custom function my site uses a lot. i put it in a > > plugin. :) " > > > > Why not fake a namespace instead? > > > > like if you had > > > > function toUpperCase() { > > //your custom "to upper case" code that > > //would conflict with JS's verion > > > > } > > > > simply saying > > > > var waseem = {}; > > waseem.toUpperCase = function() { > > //your custom "to upper case" code that > > //would no longerconflict with JS's verion > > > > } > > > > would solve the issue.... > > > > back on topic, i haven't seen anyone suggest that the original code > > > > $(function(){ > > function displayMessage(){ alert('hello world'); };}); > > > > $(function(){ > > displayMessage(); > > > > }); > > > > be written like > > > > function displayMessage(){ alert('hello world'); }; > > > > $(function(){ > > displayMessage();}); > > > > $(function(){ > > displayMessage(); > > > > } > > }); > > > > which makes a lot of sense, and is a super simple change >