Message from JavaScript discussions

February 2019

— Yeah i have already defined it to be 1


I mean when you do this

addEventListener(‘click’, x=function(){})

This will evaluate your expression assignment x=function(){} and will return the function

So the line above is almost the same as

addEventListener(‘click’, x)

That’s why it will always your conditional if (x) be true

— He's calling logic function with passed parameter when button is clicked

— The problem here is the conditional is called as son as the event trigger is set. It’s almost instantaneous.

Message permanent page

— Yeah it will be called

— And if it is called

— 0 is returned

— X is storing 0

— Which makes if(x) false

— If button clicked

— No, it’s not.

— And it is not executed