Click to See Complete Forum and Search --> : Javascript short syntax?


Flashjunky
09-17-2003, 08:34 AM
Heyup!

I keep seeing things like

Secure = (Secure != null) ? '; secure' : '';

(it's from some cookie code somewhere)

What does it all mean?!

I mean, I know what it does, I'm just a little confused as to what does which bit if you get my drift..

Heyulp!

:p

Jeff Mott
09-17-2003, 08:48 AM
if (Secure != null) is true, return '; secure', else return ''. It is essentially a one-line if statement. For more detailed information see http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/ops.html#1045406

Khalid Ali
09-17-2003, 08:49 AM
Secure = (Secure != null) ? '; secure' : '';

this simply means this

if(Secure!=null){//secure is not null
Secure = '; secure';
}else{//secure is null
Secure = "";
}

Flashjunky
09-17-2003, 10:20 AM
I thought so...

So it is just shorthand then...

Time to re-write all my functions I reckon!

Thanks Khalid :)

Khalid Ali
09-17-2003, 10:22 AM
you are welcome..:D