extjs--13--ext.apply (src,apply) and Ext.applyif (Src,apply) Two methods of use and difference comparison

Source: Internet
Author: User

Ext.onready (function () {/* * ext.apply (src,apply) and Ext.applyif (Src,apply) Two methods use and difference comparison *///ext.apply (src,apply) method to extend and modify the properties or methods of an existing object//define object Srcvar src = {name: "Tom", age:22};//definition object Applyvar apply= {sex: "Male", Age:33,name: "Jack", Sal : 10000};//uses the Ext.apply method to attribute or extend the Src object ext.apply (src,apply),////view src properties and attribute values for (var attr in src) { document.write (attr + "--" +src[attr]) document.write ("<br>")}//results as follows//name--jack//age--33//sex--man// sal--10000//from the source code and test results can be seen://With the properties in the Apply object and the SRC object in the attribute to be compared one by one, if there is no attribute in src to copy the assignment to SRC, if there is the same attribute, the value of the original property is overwritten// The result of the Ext.apply method extension is the test results above for the//*************** divider line ***********************document.write ("<br>")// The difference between ext.applyif (src,apply) and ext.apply (src,apply) is that if there is a property currently being compared in the original object, then it will not be copied, and the value of the property will of course not be modified//For example: var srcif = { Name: "Tom", Age:22};var applyif= {sex: "Male", Age:33,name: "Jack", sal:10000}; Ext.applyif (Srcif,applyif); for (Var attr in Srcif) {document.write (attr+ "----" +srcif[attr]) document.write ("<br > ")}//result is//name----tom//age----22//sex----male//sal----10000})

extjs--13--ext.apply (src,apply) and Ext.applyif (Src,apply) Two methods of use and difference comparison

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.