Introduction to the $. extend method in jQuery to extend the JSON object, jqueryjson

Source: Internet
Author: User

Introduction to the $. extend method in jQuery to extend the JSON object, jqueryjson

$. Extend can be used to extend a JSON object. One or more other objects can be used to expand an object and return the extended object.

Example 1

Merge settings and options, modify and return settings

Var settings = {validate: false, limit: 5, name: "foo"}; var options = {validate: true, name: "bar"}; jQuery. extend (settings, options );

ResultSettings = {validate: true, limit: 5, name: "bar "}

Example 2

Merge ults and options without modifying defaults.

Var empty ={}; var defaults = {validate: false, limit: 5, name: "foo"}; var options = {validate: true, name: "bar "}; var settings = jQuery. extend (empty, defaults, options );

Result

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

The above discussion about the $. extend method in jQuery to expand the JSON object is all the content shared by the editor. I hope you can give us a reference and support for the house of friends.

Related Article

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.