This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 61105
    
  66

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: 61105
    
  66

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.