码迷,mamicode.com
首页 > 其他好文 > 详细

zepto 学习笔记

时间:2016-11-25 07:32:24      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:source   extend   his   map   als   isp   for   one   alt   

1、复制

(1)浅层复制

$.extend(target, source)

比如:

var target = { one: ‘patridge‘, three: {a: "1"} },
    source = { two: ‘turtle doves‘ , forth: {b: "2"}, three: {c: "3"} }

$.extend(target, source)

结果:

技术分享

(2)深层复制

$.extend(true,target, source)

比如:

var target = { one: ‘patridge‘, three: {a: "1"} },
    source = { two: ‘turtle doves‘ , forth: {b: "2"}, three: {c: "3"} }

$.extend(true,target, source)

结果:

技术分享

2、$.isPlainObject   (v1.0+)

该方法用于判断是否是新创建的对象,即使用{}或者new Object创建的返回true,其余返回false.

3、$.grep、$.map和$.each

(1)$.grep(elements, function(value,index){})

该方法可以过滤子集,返回的还是原来的函数,该方法的function中没有this对象

使用环境:在选取数组的子集时很有用

(2)$.map(elements, function(value,index){})

该方法返回的是新的函数,该方法的function中没有this对象

使用环境:在更改数组中的所有原始值时很有用

(3)$.each(elements, function(index,value){})

该方法返回的是原来的函数,该方法的function中有this对象

使用环境:在数组中的每个元素都调用别的函数时很有用

zepto 学习笔记

标签:source   extend   his   map   als   isp   for   one   alt   

原文地址:http://www.cnblogs.com/qzccl/p/6100226.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!