Google Groups Home
Help | Sign in
Javascript 中的保留字
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
gugod  
View profile
 More options Jul 22 2007, 1:34 am
From: gugod <gugod...@gmail.com>
Date: Sat, 21 Jul 2007 22:34:13 -0700
Local: Sun, Jul 22 2007 1:34 am
Subject: Javascript 中的保留字
偶爾有些時候會把 "class"﹑"default" 這些常用的字拿來做為雜湊的鍵,但其實這兩個字是 Javascript 之中的保留字。因此
有些特別。比如說:

  foo.default

在 IE 之中是文法錯誤,必需要改寫為:

  foo["default"]

值得注意的是,在 Firefox 中兩種寫法都行。不太確定是否有規範規定這種狀態應有的正確行為。也許正確的做法是產生文法錯誤,而這確實是屬於
Javascript Engine 各自實要決定的事項。

以下列出 Javascript 裡面的保留字做備考(取自 http://javascript.about.com/library/blreserved.htm)

    * abstract
    * as
    * boolean
    * break
    * byte
    * case
    * catch
    * char
    * class
    * continue
    * const
    * debugger
    * default
    * delete
    * do
    * double
    * else
    * enum
    * export
    * extends
    * false
    * final
    * finally
    * float
    * for
    * function
    * goto
    * if
    * implements
    * import
    * in
    * instanceof
    * int
    * interface
    * is
    * long
    * namespace
    * native
    * new
    * null
    * package
    * private
    * protected
    * public
    * return
    * short
    * static
    * super
    * switch
    * synchronized
    * this
    * throw
    * throws
    * transient
    * true
    * try
    * typeof
    * use
    * var
    * void
    * volatile
    * while
    * with


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google