ÍøÂçѧԺ

w3pop.com :: ÍøÂçѧԺ :: JavaScript :: JS Guidelines

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

JavaScript
JSÊýѧ¶ÔÏó²Î¿¼
JS×Ö·û´®¶ÔÏó²Î¿¼
JSº¯Êý²Î¿¼
JSʼþ²Î¿¼
Javascript ³£ÓÃÕ..
FFºÍIEϵÄjs¼æÈÝ..
jQuery ¼òµ¥½éÉÜ
jQuery / ºËÐÄ / ..
jQuery / ºËÐÄ / ..
ÈçºÎʹÓÃJSÀ´ÅжÏ..
JavascriptÔÚIEºÍ..
3¸öjs×Ö·û±àÂ뺯Ê..
javascript ÖÐµÄ ..

JS Guidelines


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ÐÞ¸Ä:2007-05-29 ä¯ÀÀ:11955 :: ::

Some other important things to know when scripting with JavaScript. 
ʹÓÃJSʱ»¹Ó¦¸ÃÁ˽âµÄÒ»Ð©ÖØÒªÐÅÏ¢¡£


JavaScript is Case Sensitive
JSÊÇÇø·Ö´óСдµÄ

A function named "myfunction" is not the same as "myFunction" and a variable named "myVar" is not the same as "myvar".
º¯ÊýÃû³ÆÎª"myfunction"²¢²»ºÍ"myFunction"Ïàͬ£¬Í¬ÑùÒ»¸ö½Ð×ö"myVar"µÄ±äÁ¿ºÍ½Ð×ö"myvar"µÄÒ²²»Ò»Ñù¡£

JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions.
¾ÍÒòΪJSÇø·Ö´óСд-ËùÒÔµ±Ä㽨Á¢»òµ÷ÓñäÁ¿£¬¶ÔÏóºÍº¯ÊýµÄʱºò×Ðϸ¿´¿´ÄãµÄ´óд¡£


White Space
¿Õ°×

JavaScript ignores extra spaces. You can add white space to your script to make it more readable. The following lines are equivalent:
JS»áºöÂÔ¶àÓàµÄ¿Õ°×¡£Äã¿ÉÒÔÔÚÄãµÄ½Å±¾Àï¼ÓһЩ¿Õ°×À´Ôö¼Ó¿É¶ÁÐÔ¡£ÏÂÃæÁ½ÐÐЧ¹ûÊÇÒ»ÑùµÄ£º

name="Hege"
name = "Hege"

 


Break up a Code Line
´úÂë¶ÎµÄ²ð·Ö

You can break up a code line within a text string with a backslash. The example below will be displayed properly:
Äã¿ÉÒÔÔÚÎÄ×Ö´®ÖмÓÈ뷴б¸ÜÀ´½«Ò»¶Î´úÂë²ð¿ª¡£ÏÂÃæµÄÀý×Ó½«Õý³£ÏÔʾ£º

document.write("Hello \
World!")

However, you cannot break up a code line like this:
È»¶øÄã¾Í²»ÄÜÕâÑùÀ´²ð·Ö

document.write \
("Hello World!")

 


Comments
×¢ÊÍ

You can add comments to your script by using two slashes //:
Äã¿ÉÒÔʹÓÃ˫б¸ÜÀ´Ìí¼ÓÄã½Å±¾µÄ×¢ÊÍ£º

//this is a comment
document.write("Hello World!")

or by using /* and */ (this creates a multi-line comment block):
»òÕßʹÓÃ/*ºÍ*/£¨Õâ¸ö¿ÉÒÔ½¨Á¢¶àÐеÄ×¢ÊÍÇø£©£º

/* This is a comment
block. It contains
several lines */
document.write("Hello World!")

ÆÀÂÛ (2) 1 All