zoukankan      html  css  js  c++  java
  • Jquery的extend方法

    js里  两个对象   可以用 extend  来继承  属性  具体方法
    1.合并多个对象。 

    这里使用的就是$.extend()的嵌套多个对象的功能。 

    所谓嵌套多个对象,有点类似于数组的合并的操作。
    <span style="font-size:18px;">//用法: jQuery.extend(obj1,obj2,obj3,..)
    var Css1={size: "10px",style: "oblique"}
    var Css2={size: "12px",style: "oblique",weight: "bolder"}
    $.jQuery.extend(Css1,Css2)
    //结果:Css1的size属性被覆盖,而且继承了Css2的weight属性
    // Css1 = {size: "12px",style: "oblique",weight: "bolder"}
    </span>
     
     
     
    .深度嵌套对象。 
    <span style="font-size:18px;"> jQuery.extend(
    { name: “John”, location: { city: “Boston” } },
    { last: “Resig”, location: { state: “MA” } }
    );
    // 结果:
    // => { name: “John”, last: “Resig”, location: { state: “MA” } }
    // 新的更深入的 .extend()
    jQuery.extend( true,
    { name: “John”, location: { city: “Boston” } },
    { last: “Resig”, location: { state: “MA” } }
    );
    // 结果
    // => { name: “John”, last: “Resig”,
    // location: { city: “Boston”, state: “MA” } }
    </span>
     
  • 相关阅读:
    Enum, Generic and Templates
    Writing A Threadpool in Rust
    A First Look at Rust Language
    Closures in OOC
    Complexity Behind Closure
    Introduction to OOC Programming Language
    OOC,泛型,糟糕的设计。
    Enlightenment笔记
    Machine Learning/Random Projection
    Machine Learning/Introducing Logistic Function
  • 原文地址:https://www.cnblogs.com/haoerlv/p/7234600.html
Copyright © 2011-2022 走看看