News for hackers. Stuff that matters.
Re:Apple JavaScript Coding Guidelines by solutionyogi on Sunday October 31, 2010 @09:02PM (#1854935)
"To create a new member function, create a new anonymous function and assign it to the prototype property of the object. "

I prefer not to use anonymous function. I will use named function so that my stack trace is comprehensible when I am debugging.

  myObject.prototype.memberMethod = function()
  {
    // code to execute within this method
  }
becomes

  myObject.prototype.memberMethod = function memberMethod()
  {
    // code to execute within this method
  }
 
Also, what's up with naming the constructor function as 'myObject'. JS prototypical nature is confusing as is and using an example like this can only make it harder to understand.
Re:Apple JavaScript Coding Guidelines by mnemonik on Sunday October 31, 2010 @11:11PM (#1855209)
Indeed, however you have to be careful about the outer scope that the assignment is happening in (because of IE): http://kangax.github.com/nfe/#jscript-bugs

The other option, if you are on Webkit, is to assign something to the `displayName` property of a function or method. This is explained really well here: http://www.alertdebugging.com/2009/04/29/building-a-better-j...

Re:Apple JavaScript Coding Guidelines by solutionyogi on Sunday October 31, 2010 @11:37PM (#1855257)
Yeah, I should have added the warning about JScript bugs. At least the first two bugs listed on that page has been fixed in IE9.
Re:Apple JavaScript Coding Guidelines by mnemonik on Monday November 01, 2010 @01:16AM (#1855468)
Do you have a link regarding IE9 fixing the NFE bugs? Googling "ie9 named function expression" didn't yield particularly good results. Thanks.