I'm having difficulties to create new instance from an object in javascript. Try to read some answer, but still no luck.
var general_obj = {
title : '',
count : 0,
details : [],
status : 'OK'
}
function processData(input){
var result = Object.create(general_obj);
return result;
}
I wanted to create new instance from general_obj. I'm expecting the result would have the same structure as general_obj, whereby in my case the return become only
{}
instead of:
{
title : '',
count : 0,
details : [],
status : 'OK'
}
How can I achieve it ?
console.log(result.count)- it's0.Object.create()is the wrong method. If you mean "has a link togeneral_objas its prototype" then that's what your code is doing.