PDA

View Full Version : maybe a stupid question, but...



Dedix
July 4th, 2001, 11:57
does anybody know, what is the opposite of "null" in javascript?

e.g.

if (xy==null) var xy='no'
if (xy==???) var xy='yes'

so what should i put instead of ???

LastActionHero
July 4th, 2001, 12:05
Originally posted by Dedix
does anybody know, what is the opposite of "null" in javascript?

e.g.

if (xy==null) var xy='no'
if (xy==???) var xy='yes'

so what should i put instead of ???

if(xy!=null) var xy=yes

Dedix
July 4th, 2001, 12:33
thank you for the very quick response!

JALman
July 4th, 2001, 19:20
You have to understand this concept of programming a bit (please anyone help me if the following is false):

I assume you want to have the choice (if not, I recommend you should) of whether or not an event should start or not based on whether a given variable's value is null.

If the variable's value is null in JavaScript, then I doubt the value is "null," for that would be a string of text. I think a null value is represented by nothing in between the double quotes:


if (xy != "") {}

This expression above checks if the variable xy is *not* equal to the null value, make sure the condition is met by inserting an event within the double brackets.

I suggest you read some programming tutorials at www.stars.com/ (http://www.stars.com/) to find out more. I apologize for the brevity of this post, I gotta get eatin'

Have a blessed day.

Archbob
July 5th, 2001, 00:15
I'm fairly certain since I've been coding some javascript lately

that the opposite of

if (xy==null) is indeed
if(xy!=null)

its the same as in c++

lucifer
July 5th, 2001, 04:15
Originally posted by JALman
You have to understand this concept of programming a bit (please anyone help me if the following is false):

If the variable's value is null in JavaScript, then I doubt the value is "null," for that would be a string of text. I think a null value is represented by nothing in between the double quotes:


try this

var a;
if (a==null){document.write("a is null")}
if (a==""){document.write("a is empty")}

null and "" are different just as null and 0 are different

LastActionHero
July 5th, 2001, 07:03
Originally posted by Dedix
thank you for the very quick response!

You are welcome. :) As far the null is concerned correct me if I'am wrong it is a built in keyword representing void.