Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to assign dynamic value to variable in javascript

const obj = {};

function setDynamicValue(variableName, variableValue) {
  return obj[variableName] = variableValue;
}

console.log(setDynamicValue('foo', 'bar'));
 
PREVIOUS NEXT
Tagged: #assign #dynamic #variable #javascript
ADD COMMENT
Topic
Name
6+6 =