[Project_owners] JS help

Aaron Boodman zboogs at gmail.com
Sun Jul 23 17:56:19 EDT 2006


For the naysayers, there's some really fun stuff you can do with
syntax like this. For example, you can simulate threading by breaking
up long operations into small chunks, without devolving into OO state
machine madness.

function doLongThing() {
  var i = 0;

  queue(function() {
    if (i > max) {
      alert("done");
      return;
    }

    // do work here using i

    queue(arguments.callee);
  });
}

The queue() function can decide whether to call the function
immediately or delay it using whatever logic it wants. I need to write
an article about this.

- a

On 7/23/06, Karsten Düsterloh <mnenhy at tprac.de> wrote:
> Konstantin Svist aber hob zu reden an und schrieb:
> > You will be unable to use foo() even from within the function that
> > defined foo
> > source:
> > http://academ.hvcc.edu/~kantopet/old/javascript/index.php?page=adv+js+functions&parent=js+functions
> >
> > another way (i think this might be deprecated)
> > "You can make recursive calls within an anonymous function using
> > arguments.callee , which is a reference to the currently executing
> > function (even if it has no name)."
> > source: http://www.dustindiaz.com/awkward-looking-javascript/
>
> It might be worth looking at m.o directly:
> http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions#Function_constructor_vs._function_declaration_vs._function_expression
>
>
> Karsten
>
>
> Karsten
> --
> Feel free to correct my English. :)
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>


More information about the Project_owners mailing list