JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2058
Number of posts: 5158

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Question Marks Floating Around in Code -- Please Explain Posted by JediGeek709 on 18 Mar 2005 at 2:15 PM
I was looking at some borrowed code today and saw a few lines that looked similar to this:

this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];


But I have never heard of the ? operator. Could someone please try to explain why that '?' is floating around in there?
Report
Re: Question Marks Floating Around in Code -- Please Explain Posted by Jonathan on 18 Mar 2005 at 4:41 PM
: I was looking at some borrowed code today and saw a few lines that looked similar to this:
:
:
this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];

:
: But I have never heard of the ? operator. Could someone please try to explain why that '?' is floating around in there?
:
It's a short form of "if (a) b else c", but written "a ? b : c". For example:-

a = 2 > 1 ? 1 : 0; /* a is 1 (as condition is true) */
a = 1 > 2 ? 1 : 0; /* a is 0 (as condition is false) */

Jonathan

###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.