Radified Community Forums
http://radified.com/cgi-bin/yabb2/YaBB.pl
Rad Community Non-Technical Discussion Boards >> The Water Cooler >> Programming & Boolean stuff
http://radified.com/cgi-bin/yabb2/YaBB.pl?num=1317667945

Message started by Rad on Oct 3rd, 2011 at 1:52pm

Title: Programming & Boolean stuff
Post by Rad on Oct 3rd, 2011 at 1:52pm
are these two expressions synonymous in javascripit?

(x !== 1)
! (x == 1)

is there ever a time when i might prefer to use one over the other?

Title: Re: Programming & Boolean stuff
Post by MrMagoo on Oct 4th, 2011 at 9:22pm
The first expression should read (x != 1).  You have an extra = in the first one.  The second one does require 2 =, as you correctly wrote.

In this case, they will give the same result.  The first one is slightly preferable since it can be done in a single operation. 

In the first one, you are asking "is x not equal to 1?"  It is a single question.

Vs the second express, which says "is x = 1? ok, now give me the opposite of that."


Title: Re: Programming & Boolean stuff
Post by NightOwl on Mar 23rd, 2012 at 10:24am
Oh dear, MrMagoo has fallen prey to the forum glitch that lists him as an *Ex Member* on the forum homepage after a spammer has been *deleted*.  When the spammer is deleted, the next member above in the spammed thread gets this *Ex Member* designation until a new post is made in that forum so the most recent activity is updated.

This posting should accomplish that *correction*!

Radified Community Forums » Powered by YaBB 2.4!
YaBB © 2000-2009. All Rights Reserved.