[removed] Object Literal reference in own key's function instead of 'this'

后端 未结 5 537
清酒与你
清酒与你 2020-11-22 03:18

Is it problematic to reference an object literal within a function which is part of that very literal? It seems to work just fine, but I want to make sure there aren\'t othe

5条回答
  •  长情又很酷
    2020-11-22 04:10

    I don't think there are any implications off the top of my head. Just make sure you don't accidentally do this at any point:

    var obj = {
        key1: "it",
        key2: key1 + " works!"
    }
    

    As that will cause an error. Other than that, you should be good to go!

提交回复
热议问题