"Learning Notes" JavaScript coding specification-strings

Source: Internet
Author: User

Use single quotation marks for strings.

Goodvar name = ' Terence ';//badvar name = "Terence";

Strings longer than 80 characters should be wrapped using a string connector.

Goodvar msg = ' Test Information testing information Test information Test information ' + ' test information Test information Test Information Test Info Testing Information Test information ' + ' test information Test information testing information ';

Badvar msg = ' Test information Test Info test Information Testing Information Test information Test Information Test Info Testing Information Test information Test information Test information Test information Test information Testing Information Test info test information ';

Strings created with the program should use the join method of the array to concatenate strings instead of using connectors.

</pre><pre name= "Code" class= "javascript" >var items = []; var msgs;var length;var i; msgs = [{no: ' 1 ', msg: ' One ' },{no: ' 2 ', msg: ' Both '}]function Inbox (msgs) {//good for (i=0;i<length;i++) {   items[i] = ' <li> ' +msgs[i]} Return Items.join (") + ' </ul> ';//badreturn items + ' </ul> '}


"Learning Notes" JavaScript coding specification-strings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.