Такого механизма нету. Можно использовать нечто подобное (рабочий пример
https://jsfiddle.net/83bun7xt/ ):
function serialize(entity) {
return JSON.stringify({ type: entity.constructor.name, data: entity });
}
function deserialize(str, types) {
var parsed = JSON.parse(str);
return types[parsed.type] ? new types[parsed.type](parsed.data) : {};
}
function User(data) {
this.id = data.id;
this.name = data.name;
}
var user = new User({ id: 1, name: 'Nik' });
console.log('User ->', user, ' instanceOf User ===', user instanceof User);
// User -> User {id: 1, name: "Nik"} instanceOf User === true
var userJSON = serialize(user);
console.log('Serialized user ->', userJSON);
// Serialized user -> {"type":"User","data":{"id":1,"name":"Nik"}}
var restoredUser = deserialize(userJSON, { 'User': User });
console.log('Deserialized user ->', restoredUser, ' instanceOf User ===', restoredUser instanceof User);
// Deserialized user -> User {id: 1, name: "Nik"} instanceOf User === true
//