Ah, new $, is possible and therefore not barred ... Left in there as a sort of a land-mine for the newcomers ? Or as an esoteric test for GC developers ? Highly useless it seems to me.
Back to reality and jQuery. $ is defined as: function(selector, context) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init(selector, context); } Maybe I am just searching for ECMA "harmony", but will $() definition that throws an exception if new-ed , be usefull : try { new $ ; } catch ( x ) { // x. message == "Can not new $()" } Au-contraire : will this hurt anyone ? Is exception throwing porgramming idiom damaging for jQuery? --DBJ PS: if Python was choosen as a Netscape scripting language, World would be a better place ... If nothing else its name is less ridiculous ... ;o) On May 14, 9:04 am, Andrea Giammarchi <andrea.giammar...@gmail.com> wrote: > it's called JavaScript :D > > jokes a part, every function is a constructor as well so new function is > always valid. > > If the function returns an object, it does not matter which "new" is because > it will be an instance of returned object one. > > if it is a primitive it will simply be lost: > > var a = new function(){return 123;}; > // a is an instance of anonymous function > > this allows us to create Python like initializations: > > function PythonLike(){ > return this instanceof arguments.callee ? this : new arguments.callee; > > }; > > alert(PythonLike() instanceof PythonLike); > alert(new PythonLike() instanceof PythonLike); > > true in both cases > > jQuery returns a new jQuery.prototype.init where init method shares the same > prototype ... better now? :-) > > On Wed, May 13, 2009 at 11:57 PM, DBJDBJ <dbj...@gmail.com> wrote: > > > Why is this allowed : > > > var jq = new $ ; > > > Does it matter? > > > -- DBJ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---