How to set the variable name property in the object?

function ajax (type,value){
 var request = {
 type: value
};
}

As in the request object to set the name properties?
July 9th 19 at 11:17
1 answer
July 9th 19 at 11:19
Solution
es2015
function ajax (type, value){
 var request = {
 [type]: value
};
}

es5
function ajax (type,value){
 var request = {};
 request[type] = value;
}

Find more questions by tags JavaScript