代码之家  ›  专栏  ›  技术社区  ›  Eran Betzalel

活动:“是”和“活动”:“是”之间的区别是什么?

  •  10
  • Eran Betzalel  · 技术社区  · 15 年前

    我用Firebug测试了这两个案例,结果看起来非常相似:

    >>> var x = {"active": "yes"}
    >>> x.active
    "yes"
    >>> var x = {active: "yes"}
    >>> x.active
    "yes"
    

    但我很确定这两者之间有一些区别,甚至可能是与性能相关的区别。底线-我想知道活动:“是”和“活动”:“是”之间是否存在差异。

    5 回复  |  直到 15 年前
        1
  •  28
  •   meder omuraliev    15 年前

    delete

    JSON spec


    {key:'value'} {"key":"value"}

    >>> ({delete:1})
    SyntaxError: Unexpected token delete
    >>> ({'delete':1})
    Object
    

    >>> ({first-name:'john'})
    SyntaxError: Unexpected token -
    >>> ({'first-name':'john'})
    Object
    >>> ({'first-name':'john'})['first-name']
    "john"
    
        2
  •  11
  •   Quentin    15 年前

    active

        3
  •  3
  •   Gumbo    15 年前

    {"active": "yes"} {active: "yes"}

        4
  •  2
  •   Sean Vieira    15 年前

    {"active": "yes"} {'active': "yes"} {"active": 'yes'} {active: 'yes'}

    "

        5
  •  0
  •   Richard Marskell - Drackir Sunil Tandon    15 年前

    active
    http://json.org/
    object string