How to create and clone a JSON object?

This is what I do and it works like a charm

if (typeof JSON.clone !== "function") {
    JSON.clone = function(obj) {
        return JSON.parse(JSON.stringify(obj));
    };
}

Just do

var x = {} //some json object here
var y = JSON.parse(JSON.stringify(x)); //new json object here

As of ES6. Object.assign is a good way to do this.

newjsonobj = Object.assign({}, jsonobj, {})

The items in the first argument mutate the existing object, and the third argument are changes in the new object returned.

In ES7 it is proposed that the spread operator be used.

newjsonobj = {...jsonobj}