0
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);

I need final result of d = {1:2};

sahil
  • 99
  • 1
  • 3
  • 10

1 Answers1

3

You can use computed property

var c = {[a] : b};
guest271314
  • 1
  • 12
  • 91
  • 170