.clone()

Description

Creates a deep copy of the object, duplicating all nested arrays and objects so that the returned copy shares no references with the original.

Parameters

clone takes no parameters.

Usage

original = {a:1,b:{c:2}}
copy = original.clone()
copy.b.c = 10
log original.b.c // 2 (unaffected)

Last updated

Was this helpful?