I'm trying to find a string in any way it is written in an object received.
example
"OUTPUT", "OUT PUT", "out put", "ouT Put"
test.hasOwnProperty("OUTPUT")
works for only this case. I do not want to repeat the same for each case. Is there a better way to get this done?
答案 0 :(得分:0)
var object = {"OUTPUT":"value"};
var prop1 = "OUTPUT",
prop2 = "OUT PUT",
prop3 = "out put",
prop4="ouT Put";
console.log(object.hasOwnProperty(encodeURI(prop2).replace(/%20/g,'').toUpperCase()));
console.log(object.hasOwnProperty(encodeURI(prop2).replace(/%20/g,'').toUpperCase()));
console.log(object.hasOwnProperty(encodeURI(prop2).replace(/%20/g,'').toUpperCase()));
console.log(object.hasOwnProperty(encodeURI(prop2).replace(/%20/g,'').toUpperCase()));