18.6.25 • Published 6 years ago

lodash.clonejson v18.6.25

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

lodash.cloneJSON

_.cloneJSON(value)

Converts a JavaScript value to a JSON string and then parses it back to a JavaScript value. This function is a shortcut for JSON.parse(JSON.stringify(value)).

argumentdescription
valueThe value to clone.

Returns the cloned value.

dependencies

setup

npm

npm install lodash.clonejson

ES module

import _ from 'lodash';
import 'lodash.clonejson';

Node

const _ = require('lodash');
require('lodash.clonejson');

browser

<script src="https://unpkg.com/lodash"></script>
<script src="https://unpkg.com/lodash.clonejson"></script>

usage

let array = [{a: 11}, {b: 22}];
let arrayCopy = _.cloneJSON(array);
console.log(array[1] === arrayCopy[1]); // => false