Hey! @ Beast, your NG API is out--angular.copy

Source: Internet
Author: User

@ The beast's NG API Learning--Angular.copy

Angular.copy

Create a deep copy of the object or number.

Format: angular.copy (source, [destination]);

Source: The object being copied

Destination: Received Object [Note: The parameter type is an object or an array]

Using code:

var obja, OBJD = []; obja:undefined objd:[]
var objb = {text: "Hello World"};
var OBJC = {text: "Hai", Value: "Test"};
Obja = Angular.copy (OBJB); obja:{text: "Hello World"} objb:{text: "Hello World"}
Angular.copy (OBJC, OBJD);//objc:{text: "Hai", Value: "Test"} objd:[text: "Hai", Value: "Test"]

@ Beast to angular API one after the translation of their own, and then write the code to run successfully, just recorded ... @ the Beast knows there is a similar translation on the Internet, but @ the Beast has the Pride of the Beast. Do not copy the results of others, must be their own translation, write their own code, see the source (part, not all ...) I've seen jquery before, all of them are tired, so I can get a deeper understanding of these methods ...

OK, tear down angular.copy, or according to the above code to explain ...

First of all, Obja = Angular.copy (OBJB), the meaning of the OBJB copy, and then the contents of the copy depth assigned to a, when a from the original undefined into the object{text: "Hello World"}. However, @ the Beast put Obja and objb in comparison with = =, found that the return is false, I also put obja = OBJB, and then to the ratio of = =, then return is true. This pit @ The beast does not know how to fill it at the moment (I'm afraid I'm shallow ...) Is there a great God willing to answer? ), because TypeOf under Obja and OBJB, are object, and the properties/values are the same ....

Then say Angular.copy (OBJC,OBJD), this is OBJC copy to OBJD, and then I direct Var objd, found that after the execution of this sentence objd or undefined, and then the beast went to see the API, Discovery format: The Receiving object in Angular.copy (source, [destination]) is the one with [], and then the API website gives the explanation, this parameter is an object or an array, OK, then the @ Beast will try it with objects or arrays ... It sure did.

Well, Angular.copy's explanation is over here. The beast's understanding of angular.copy

Hey! @ Beast, your NG API is out--angular.copy

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.