Common Methods for cloning objects and arrays in js
Source: Internet
Author: User
Ext can be cloned using the following methods: varnewJsonExtclone (json), varnewJsonExtclone (json), and varnewJsonExtArrayclone (json). JQuery's method: Deep copy [iterative ]: varnewJsonjQueryextend (two clone methods of tr Ext: Object cloning and data cloning: var newJson = Ext. clone (json); only Arrays can be cloned: var newJson = Ext. array. clone (json); JQuery method: Deep copy [can be iterated]: var newJson = jQuery. extend (true, {}, json); shallow copy [non-iteration]: var newJson = jQuery. extend ({}, json); var newJson = $. map (json, function (n) {return n ;}); grams of the array Method: var newJson = json. concat (); var newJson = json. splice (0); the above methods are to copy a new object or array, however, if you directly use the parent [iframe situation] method to get the object in the parent window, there will be a [Reference relationship]. Note that you can change the method to the data transmission method.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service