vdogamer
vdogamer

Reputation: 15

Javascript function using the "+=" operator

I'm studying for an HTML certification an ran across a syntax like this:

 foo.click() += some_other_function;   // supposedly to invoke another function
                                       // when the foo HTML element is clicked.

I can't find any information on this. Can this be done in JavaScript?

Upvotes: 0

Views: 59

Answers (1)

Jamiec
Jamiec

Reputation: 136094

In general, the x += y operation in javascript is just shorthand for x = x + y

Using this with a function call, makes little sense. There is probably some contrived way to make the code you posted not error, but its hard to imagine where it could do something meaningful.

So:

Can this be done in JavaScript?

No, not really.

Upvotes: 2

Related Questions