V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
mylab
V2EX  ›  Vue.js

js 中 a.b 与 a[b]除了书写外,有什么区别?

  •  
  •   mylab · Nov 8, 2018 · 3176 views
    This topic created in 2731 days ago, the information mentioned may be changed or developed.

    es6 中,同事有的写 data[name],大部分使用 data.name 写法,请问有什么区别?

    Supplement 1  ·  Nov 8, 2018
    准确说是 data['name'] 和 data.name 区别

    谢谢 1 楼严格的逻辑
    jy02534655
        1
    jy02534655  
       Nov 8, 2018
    data[name]中的 name 是变量,data.name 中的 name 就是固定的值
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2509 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:36 · PVG 16:36 · LAX 01:36 · JFK 04:36
    ♥ Do have faith in what you're doing.