How to serialize an object in JavaScript?

Viewed 51094

For example I have class:

function Test() {
}

Test.prototype = {
    'setTest' : function(test) {
        this.test = test;
    }
}
var test = new Test();
Test.setTest('test');

I want to save object test in database. How to serialize object test to string? (methods, variables, etc)

6 Answers
Related