JS Clone method

Source: Internet
Author: User

Methods of jquery:

Deep copy "can iterate": var Newjson = Jquery.extend (true,{}, JSON);

Shallow copy "Cannot iterate": var Newjson = Jquery.extend ({}, JSON);

var Newjson = $.map (Json,function (n) {return n;});

Methods for cloning arrays:

var Newjson = Json.concat ();

var Newjson = json.splice (0);

There are several ways to copy a new object or array, but if you go directly to the parent "IFRAME case" in the way of the parents of the object, there is a problem "referential relationship", you need to note that you can change the way to pass the data.

Transferred from: http://blog.csdn.net/jcx5083761/article/details/12007443

JS Clone method

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.