Click to See Complete Forum and Search --> : breaking a Long JavaScript Line
daneb
August 4th, 2000, 04:14 AM
Good day!
I'm sorry for posting a non-ASP question here but since my question is web-related, here it goes. There are times when you are writing your code in JavaScript and you need to break your code in the next line (especially if you're not using a text editor that doesn't automatically wrap lines). How do you do this in JavaScript? For instance, VB has the underscore character (_). Thanks in advance!
Rick Leinecker
August 13th, 2000, 07:47 PM
JavaScript follows the same syntax rules of C++ for the most part.
For instance, the following:
if( nCount > 15)
{
DoFunction( Argument1, Argument2, Argument3, Argument4 )
}
can be made into the following:
if( nCount > 15)
{
DoFunction( Argument1,
Argument2, Argument3, Argument4 )
}
The major rule you don't want to break is slittiing a string constant. The following:
alert( "This is a really long string that I might want to break up." );
can't legally be made into:
alert( "This is a really long string
that I might want to break up." );
Hope this helps. Send me more specific questions.
daneb
August 14th, 2000, 02:30 AM
Thanks for the reply. I have tried your solution and it worked. However, for the second example you have cited, that is, breaking a string constant, I also found a solution. The concatenate operator (+) must be used.
For instance:
alert("I am a long string " +
"broken into two lines.")
Thanks again.
Rick Leinecker
August 14th, 2000, 08:09 PM
Excellent. That's one I haven't used yet.
Are there any, though, that you can't figure out?
daneb
August 14th, 2000, 08:35 PM
Thanks for the concern. As of now, this is the only problem I have encountered. Maybe I'll post questions later as I continue to learn different Web technologies. This has been a great site. Keep up the good work, and thanks again!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.