The Extend method of jquery

Source: Internet
Author: User

Using Flot.js to use the Extend method of jquery

About the Extend method I'll go through the manual, deepen my understanding, and honestly I don't understand.

Extend extends an object with one or more other objects, returning the object being extended.

If you do not specify target, the jquery namespace itself is extended, which helps plug-in authors add new methods as jquery. If the first argument is set to True, jquery returns a deep copy, recursively copying the found object. Otherwise, the copy will share the structure with the original object. Undefined properties will not be copied, and properties inherited from the object's prototype will be copied.

Parameters

Target, "Object1", "objectn"

Target: An object, if the attached object is passed to this method then it will receive the new attribute if he is the only parameter that will extend the namespace of jquery.

Object1: The object to be merged into the first object

OBJECTN: An object to be merged into Nth object

"Deep", target,object1,objectn

Deep: If set to True, the merge is recursive.

Target: object to be modified

Object1: The object to be merged into the first object

Example

Merge settings and options, modify and return settings.

var settings = {validate:false,limit:5,name: ' foo '}

var options = {validate:true,name: "Bar"}

$.extend (settings,options);

Results:

Settings = = {validate:true,limit:5,name: "Bar"}

Merge default and options, and return to Settings

var empty ={};

var default= {validate:false,limit:5,name: "foo"};

var options = {validate:validate:true,name: "Bar"};

var settings = $.extend (empty,default,options);

Results:

Settings ={validate:true,limit:5,name: "Bar"};

Empty = {validate:true,limit:5,name: "Bar"}

The Extend method of jquery

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.