JavaScript 保留词

JavaScript 保留词
在 JavaScript 中,您不能把这些保留词作为变量、标记或函数名来使用:

abstract    arguments    await*    boolean
break    byte    case    catch
char    class*    const    continue
debugger    default    delete    do
double    else    enum*    eval
export*    extends*    false    final
finally    float    for    function
goto    if    implements    import*
in    instanceof    int    interface
let*    long    native    new
null    package    private    protected
public    return    short    static
super*    switch    synchronized    this
throw    throws    transient    true
try    typeof    var    void
volatile    while    with    yield
被删除的保留词
以下保留词已被从 ECMAScript 5/6 标准中删除:

abstract    boolean    byte    char
double    final    float    goto
int    long    native    short
synchronized    throws    transient    volatile
请不要将这些保留词用作变量。并非所有浏览器都完全支持 ECMAScript 5/6。

JavaScript 对象、属性和方法
您还应该避免使用 JavaScript 内建对象的名称、属性和方法:

Array    Date    eval    function
hasOwnProperty    Infinity    isFinite    isNaN
isPrototypeOf    length    Math    NaN
name    Number    Object    prototype
String    toString    undefined    valueOf
其他保留词
JavaScript 能够在很多应用程序中被用作编程语言。

您还应该避免使用 HTML 和 Window 对象和属性的名称:

alert    all    anchor    anchors
area    assign    blur    button
checkbox    clearInterval    clearTimeout    clientInformation
close    closed    confirm    constructor
crypto    decodeURI    decodeURIComponent    defaultStatus
document    element    elements    embed
embeds    encodeURI    encodeURIComponent    escape
event    fileUpload    focus    form
forms    frame    innerHeight    innerWidth
layer    layers    link    location
mimeTypes    navigate    navigator    frames
frameRate    hidden    history    image
images    offscreenBuffering    open    opener
option    outerHeight    outerWidth    packages
pageXOffset    pageYOffset    parent    parseFloat
parseInt    password    pkcs11    plugin
prompt    propertyIsEnum    radio    reset
screenX    screenY    scroll    secure
select    self    setInterval    setTimeout
status    submit    taint    text
textarea    top    unescape    untaint
window
HTML 事件处理程序
此外您应该避免使用所有 HTML 事件处理程序的名称。

例如:

onblur    onclick    onerror    onfocus
onkeydown    onkeypress    onkeyup    onmouseover
onload    onmouseup    onmousedown    onsubmit

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值