View Full Version : What does "==" mean in JavaScript? Is it the same as "=" ?
chelentano
08-27-2002, 09:29 PM
Is it the same as "=" ?
no its not the same.
"==" is the way to check if something is equal to something else
for example
if(document.title=="hi")alert("title = hi");
the single = sign means to set a variable to something.
like this
var me="eak";
chelentano
08-27-2002, 09:52 PM
Thank you, clear answer
adios
08-28-2002, 12:15 AM
Assignment operator:
http://www.javaworld.com/javaworld/jw-04-1997/jw-04-javascript.html
Equality/identity operators:
http://www.webreference.com/js/tips/991205.html
:cool:
whammy
08-28-2002, 12:23 AM
That's one of the hardest errors to find when you've been looking at code all day, too. I don't know how many times I've used an assignment operator instead of a strict equality sign.
After you find that you did that in about 15 scripts though (since in VBScript (yech) they are the same thing), you kind of know to check that first, lol.
What's funny is now that I rarely do that, I was fixing some other developer's script at work (he wasn't sure why it wasn't working) and he did the exact same thing, lol.
adios
08-28-2002, 12:31 AM
Ditto, whammy. Older versions of Netscape 'fixed' this for you ("test for equality (==) mistyped as assignment (=)? Assuming equality test
") thereby giving more headaches. Kind of the opposite of a debugger.
http://javascript.internet.com/debug-guide.html
whammy
08-28-2002, 12:35 AM
Yeah, what stinks is it automatically works as an assignment operator in IE instead of giving you an error (in an if statement)!
I hope the famed "Mozilla" fixes this with its strict error reporting - but to be honest I haven't had the time to delve into javascript much as of late. :-/
joh6nn
08-28-2002, 12:38 AM
mozilla catches it, even without strict error reporting, if i remember correctly. it hasn't happened to me lately, but the last time it did, i'm pretty sure moz caught it for me.
whammy
08-28-2002, 12:41 AM
Sweet, I'll have to install it again for that (and I want to check out the skins and stuff - never really had time to do that yet!). I recently formatted both my home and work machines...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.