On Tue, May 31, 2011 at 12:16 PM, kodq <[email protected]> wrote: > var a = print('blabla'); // normal function > Class.afunction(); // class function > .. > > It works fine separately, but if I want to add to the same > ObjectTemplate, it crashes. > Can anybody answer me, why that is? >
Does it crash when you add it or when you run it? In the latter case, it can only work as a non-class function if the bound function does NOT use class-specific bound data, e.g. the native 'this' pointer of your bound class. When it is called in a global context, the 'this' object is the implicit global object. >From the above example it is not clear if you mean a "static" class-level function or a member function. e.g.: MyClass.foo() vs: var x = new MyClass(); x.foo(); "global" functions don't really exist in JS - they are members of the "invisible" (and often unnamed) global object. -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
