This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android 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: 63052
    
  69

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: 63052
    
  69

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.
 
 
subject: simple question but weird.
 
It's not a secret anymore!