Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes simple question but weird. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "simple question but weird. " Watch "simple question but weird. " New topic
Author

simple question but weird.

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
var i = 0;
myform['info.rates['+i+'].coupon'];

1. here, '+i+' , what is its meaning? so weird .

2. what is the rule using "" and ''? which is defined as standard? '' could include '' inside?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

1) It's just simple string concatentation. Perhaps if it were written:

'info.rates[' + i + '].coupon'

would it make more sense to you?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

2) Either double or single quotes can be used to delimit strings.

To use the same quote character inside the string as is used to delimit it, you need to escape the internal quote with the back-slash character. For example:

'I saw O\'Brien the other day'
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
thanks. I got it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: simple question but weird.
 
Similar Threads
javascript:window.close() does not work with NN7.1
'==' operators with Wrapper class
Weird dream
package problem????
use of static method in web development