JavaScript variable assignments from tuples

前端 未结 13 1335
[愿得一人]
[愿得一人] 2020-12-04 18:26

In other languages like Python 2 and Python 3, you can define and assign values to a tuple variable, and retrieve their values like this:

tuple = (\"Bob\", 2         


        
13条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 19:07

    You can do something similar:

    var tuple = Object.freeze({ name:'Bob', age:14 })
    

    and then refer to name and age as attributes

    tuple.name 
    tuple.age 
    

提交回复
热议问题