Json.stringify problem

var a = {

b(){
    consoel.log(1);
}

}
json.stringify (a);

/ / a = {}

what if I want him to keep the function b and change the string?

Jun.30,2021

clipboard.png


clipboard.png


var a = {
    b() {
        consoel.log(1);
    }
}
console.log(a['b'] + '');

perfect


function is not a valid JSON data type. If you want to keep it, you can force toString to convert

.
Menu