js.clone

2019-11-19 admin

js.clone是什么

什么是js.clone,Deep clone any object with circular references

js.clone使用教程帮助文档

Install

npm install js.clone --save

Usage

import Clone from "js.clone";

var a, b, c;

a = {
	null:     null,
	boolean:  true,
	number:   1,
	string:   "string",
	regexp:   /regexp/,
	function: function(){},
	array:    ["array"],
	object:   {foo: "bar"}
}

b = Clone( a );

a == b // false

a.array.push( 1 );
a.array // > ["array", 1]
b.array // > ["array"]

// Circular links

a.circular = a;
a.circular === a          // > true
c = Clone( a );
c.circular === c          // > true
c.circular === a.circular // > false

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-79456.html

文章标题:js.clone

回到顶部