转载链接:https://blog.csdn.net/lihefei_coder/article/details/82499520

//第一种方式 
 var key = 'name';
 var json = {};
 json[key] = 'zhangshan';
 console.log(json.name);

//第二种方式
 var key = 'name';
 var json = {
     [key]: 'zhangshan'
 };
 console.log(json.name);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2021-10-20
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2021-06-19
  • 2021-11-18
相关资源
相似解决方案