I have code
let letters = [
{"ae": "a"},
{"ac": "c"}
];
String.prototype.swapLetters = function(){
return this.replace(/ae/g, 'a').replace(/ac/g, 'c');
}
var decLetter= new String(response[i].name).swapLetters();
How can I use my prototype function with JSON object values? JSON will be generated dynamically.
JSON.stringify, call your function, then useJSON.parseto change it back into an object. It entirely depends on what you want to do, your question is very vaguelettersis an array of objects. JSON is a text format.