Welcome to the Linux Foundation Forum!

LFW211 JSNAD CH-9 LABS-1

So, I have the solution of

  1. ee.once('tick', listener)

But can anyone explain why the following options do not work?

  1. ee.once('tick', listener())
  2.  

OR

  1. ee.once('tick',
  2. () => {
  3. listener()
  4. }
  5. )

Seems like most of the time I waste is dancing around silly syntax errors like this and I wish I understood when I'm permitted to pass an empty constructor to a function.

Comments

  • Posts: 160

    @samuelbernardy yes knowledge of syntax certainly helps, but it gets more familiar and therefore easier over time

    the format is:
    ee.once(name, listenerFunction)

    So your first one works because you're passing a function, the second one doesn't work because you're passing whatever listener returns (you're calling the function) which I expect in this case is undefined and so you'd see an error like "undefined is not a function"

    And the last case, must be a false negative for you because that will also work, you're passing a function which is called once tick event is emitted, and that function in turns calls the listener function.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training