JavaScript保留关键字及危险变量名
JavaScript保留关键字及危险变量名 定义变量名需谨慎
在开发过程当中,如果没有必要就尽可能少的使用以下列出的单词作为变量名称或者属性名称,关键字是严格不允许,而浏览器定义的变量名或者类名在使用的时候注意确保作用域
一、现在 EMCAScript 中的关键字:
break | case | catch | continue |
default | delete | do | else |
finally | for | function | if |
in | instanceof | new | return |
switch | this | throw | try |
typeof | var | void | while |
with |
二、将来EMCAScript 5中可能使用的关键字:
abstract | boolean | byte | char |
class | debugger | double | enum |
extends | final | float | goto |
implements | int | interface | long |
native | package | private | protected |
public | short | static | super |
synchronized | throws | transient | volatile |
三、 JavaScript2.0(future) 不明确提到的关键字:
as | const | export | import |
is | use |
四、绝大部分浏览器中预定义的一些变量名和类名:
Anchor | anchors | Applet | applets |
Area | Array | Body | Button |
Checkbox | Date | document | Error |
EvalError | FileUpload | Form | forms |
frame | frames | Function | Hidden |
History | history | Image | images |
Link | links | location | Math |
MimeType | mimetypes | navigator | Number |
Object | Option | options | Password |
Plugin | plugins | Radio | RangeError |
ReferenceError | RegExp | Reset | screen |
Script | Select | String | Style |
StyleSheet | Submit | SyntaxError | Text |
Textarea | TypeError | URIError | window |
五、全局属性及方法:
Infinity | NaN | undefined | decodeURI |
decodeURIComponent | encodeURI | encodeURIComponent | escape |
eval | isFinite | isNaN | parseFloat |
parseInt | unescape |
六、Window对象的属性和方法:
1、property:
closed | Components | content | controllers |
defaultStatus | directories | document | frames |
history | innerHeight | innerWidth | length |
location | locationbar | menubar | name |
navigator | opener | outerHeight | outerWidth |
pageXOffset | pageYOffset | parent | personalbar |
pkcs11 | prompter | screen | screenX |
screenY | scrollbars | scrollX | scrollY |
self | statusbar | toolbar | top |
window |
2、Methods:
alert | back | blur | captureevents |
clearInterval | clearTimeout | close | confirm |
dump | escape | focus | forward |
getAttention | getSelection | home | moveBy |
moveTo | open | prompt | |
releaseevents | resizeBy | resizeTo | scroll |
scrollBy | scrollByLines | scrollByPages | scrollTo |
setCursor | setInterval | setTimeout | sizeToContents |
stop | unescape | updateCommands |
七、事件:
onabort | onblur | onchange | onclick |
onclose | ondragdrop | onerror | onfocus |
onkeydown | onkeypress | onkeyup | onload |
onmousedown | onmousemove | onmouseout | onmouseover |
onmouseup | onpaint | onreset | onresize |
onscroll | onselect | onsubmit | onunload |
八、特定浏览器中预定义的变量名和类名:
all | assign | clientInformation | element |
embed | embeds | event | frameRate |
getClass | java | JavaArray | JavaClass |
JavaObject | JavaPackage | layer | layers |
netscape | offscreenBuffering | opener | packages |
secure | status | sun | taint |
toSource | toString | untaint | valueOf |
posted on 2012-03-30 15:07 前端组www.qianduanzu.com 阅读(334) 评论(0) 编辑 收藏 举报