When we concatenate a string to an object, it automatically converts all the values into string.
Is there a way where it is not converted to a string or the string can be converted back to a statement.
I'm trying to do something like if I type length, it adds together to the string variable and counts the length of the string.
var property = prompt("Add the Property");
var myObject = "This is the String";
var propertyCombinedWithObject = myObject + "." + property;
console.log(propertyCombinedWithObject);
The result is a string "This is the String".length rather than counting the numbers of the string.
I have tried
eval(propertyCombinedWithObject)
but it doesn't work.