Page 1 of 1

Test for Javascript equality operator - Servoy Editor

PostPosted: Thu Jul 26, 2007 11:11 pm
by Michael Mooney
This is simply to rescue me when I have not had enough coffee or can't see the woods for the trees. I recently spent wading through some code for a few hours and lo and behold: I had used a single "=" instead of a "==" (as in if (x ==testvar)). As you might guess I *have* been down this road before ... yes, I do know better :oops: and with all of the attendant variable re-assignment fun of this mistake.

A button or special highlighting to check code for inappropriate (likely) use of the equality operator(s) would be handy.

It's would be one of those little nice-to-have's ... in 4.0 or whenever ...

PostPosted: Thu Jul 26, 2007 11:14 pm
by pbakker
You do know that if (var x=myfunction()) or if(x=y) is valid code though?

Paul

PostPosted: Thu Jul 26, 2007 11:27 pm
by Michael Mooney
Paul,

Sure do ... hence my use of the word "likely". The editor would only suggest that I might have made a mistake (ie - the code could be ok as in your examples). It's just that when one comes from other languages that I am in the habit of using a single '=' so the '==' isn't in my brain as readily :-).

Again, it's definitely in the nice-to-have-category (but only if it will aid the community as a whole ... perhaps it might be a nuisance to other coders).

Michael

PostPosted: Thu Jul 26, 2007 11:48 pm
by IT2Be
Hmm, would have to be an option and not something fixed.

I use both and would not like to be bothered all the time with a message saying that I may have done something wrong...