How replacer argument function extract key and value from object value and mapped it to its key and value argument in JSON.Stringify(value, replacer, space) method.
I understood that key of the object become the key parameter of the replacer function and value become value parameter of this function.
let user={name:"anup", age:22};
JSON.stringify(user,function(key,value){
if(typeof value==="string"){
return undefined;
}
return value;
},null);
Here name becoming the key of the replacer function and "anup" becoming the value of the replacer function thats fine, but my question is how this mapping is happening? Generally we call any method by passing argument in that method call, like
function a(c,d){
// logic
}
a(2,3);
But here in stringify method we are not passing any such thing to the replacer function or callback function, then how it is getting mapped?
Actually, I'm a newbie in javaScript world, so something I'm unable to understand. If you guide me in this regard , I'll be very thankful to you.