Welcome, Guest. Please Login
 
  HomeHelpSearchLogin FAQ Radified Ghost.Classic Ghost.New Bootable CD Blog  
 
Page Index Toggle Pages: 1
Send Topic Print
Programming & Boolean stuff (Read 5316 times)
Rad
Radministrator
*****
Offline


Sufferin' succotash

Posts: 4090
Newport Beach, California


Back to top
Programming & Boolean stuff
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?
 
WWW  
IP Logged
 

MrMagoo
Übermensch
*****
Offline


Resident Linux Guru

Posts: 1026
Phoenix, AZ (USA)


Back to top
Re: Programming & Boolean stuff
Reply #1 - 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."

 
WWW  
IP Logged
 
NightOwl
Radministrator
*****
Offline


"I tought I saw a puddy
tat..."

Posts: 5826
Olympia, WA--Puget Sound--USA


Back to top
Re: Programming & Boolean stuff
Reply #2 - 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*!
 

____________________________________________________________________________________________

No question is stupid ... but, possibly the answers are Wink !
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print