View Single Post
Old 01-24-2013, 02:27 AM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,248
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by WolfShade View Post
I am not sure, but I don't think var name = "data" +
"more data" +
"even more"; is valid or good JS.
WHAT???

Pardon, but how did you come by that belief?

Of course it's both valid and good JavaScript.

The + operator, whether used to really do arithmetic addition or string concatenation, returns the added/concatenated value as its result. So of course you can then add or concatenate further.

If you don't think that's legal, look at this:
http://www.codingforums.com/showpost...2&postcount=10

Look at the next to last statement in all that JS code.
Code:
NewCode =  topR + midR + name + ": " + sign +" "+ plevel 
        + "<BR> XP: "+ (EXP-showxp) 
        +"<BR> Experience needed: " +  (xpup-EXP)
        + "<BR>Overall Experience:" + (xneeded * EXP / xneeded) 
        +"<br><!-- placeholder --><br><br>"
(It's not very good HTML, but it's perfectly legal and correct JavaScript code.)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote