darasion

原来 IE 浏览器不能用保留字作为对象的属性哦。

  •  
  •   darasion · Oct 26, 2010 · 5177 views
    This topic created in 5876 days ago, the information mentioned may be changed or developed.
    我用自建一个对象这样引用“ obj.delete ”就会报错。而 chrome 和 firefox 都通过了。
    4 replies  •  1970-01-01 08:00:00 +08:00
    chone
    chone
    Oct 26, 2010
    1
    改成 obj['delete'] 试试
    darasion
    darasion
    OP
    Oct 26, 2010
    2
    @chone 不用了,我感觉还是换个名字比较安全。
    darasion
    darasion
    OP
    Oct 26, 2010
    3
    想了一下,IE 这个问题实际上还是有道理的。

    比如这样可能会造成混淆:

    with(obj){
    delete ...
    }
    chone
    chone
    Oct 26, 2010
    4
    @darasion 保留字用做key一般会有语法错误,不过换做string就不会有问题,当然了不用最好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:00 · PVG 07:00 · LAX 15:00 · JFK 18:00
    ♥ Do have faith in what you're doing.