.clone()

Description

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

Parameters

clone takes no parameters.

Usage

original = [1,2,3]
copy = original.clone()
copy[1] = 10
log original[2] // 1 (unaffected)

Last updated

Was this helpful?