Loading ...
Sorry, an error occurred while loading the content.

1732Re: Circular Function Definitions

Expand Messages
  • Douglas Crockford
    Jan 8, 2011
      --- In jslint_com@yahoogroups.com, "Felix E. Klee" <felix.klee@...> wrote:
      >
      > If I write code such as the following, then JSLint complains that "f" is
      > not defined.
      >
      > var sendToServer;
      >
      > function callback(moreToDo) {
      > // do something ...
      > if (moreToDo) {
      > f();
      > }
      > }
      >
      > function f() {
      > sendToServer('xyz', callback);
      > }
      >
      > What's the most elegant solution to get rid of the error message?


      ` var sendToServer;
      `
      ` function f() {
      ` sendToServer('xyz', function (moreToDo) {
      ` // do something ...
      ` if (moreToDo) {
      ` f();
      ` }
      ` });
      ` }
    • Show all 17 messages in this topic