javascript - JSON stringify and then parse works unexpectedly for the object with local variable -


why json stringify , parse not working object. works bad objects local variables?

function task(description) {     var _description = description;      this.getdescription = function() {         return _description;     } }  var task = new task('wash car'); console.log(task.getdescription()); var json = json.stringify(task); console.log(json.parse(json).getdescription()); 

json can't stringify functions (and it's not supposed able to).

but technically when need stringify object should not need functions. can pass object within application.

edit:

if need object stored locally saving functions along not idea anyway. can store properties of object , create new instance when retrieve it.


Popular posts from this blog

html/hta mutiple file in audio player -

debugging - Reference - What does this error mean in PHP? -