console.log(a) ; // console window result= 1
console.log(b);// console window result= 2
var c = {a : b};// any recommendations here?
var d = JSON.stringify(c);
d = encodeURIComponent(d);
我需要d = {1:2}的最终结果;
答案 0 :(得分:3)
您可以使用计算属性
var c = {[a] : b};