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

Konckout学习——observableArray随笔

时间:2015-07-17 18:15:17      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:

1、indexof

  The indexOf function returns the index of the first array item that equals your parameter. For example,myObservableArray.indexOf(‘Blah‘) will return the zero-based index of the first array entry that equalsBlah, or the value -1 if no matching value was found.  

  个人理解:observableArray.indexOf(key)函数返回的是observableArray数组里面第一个和“key”相同的数组项的索引(即下标),如果数组里面没有与“key”相同的数组项,则返回“-1”。例如:

1 var strObservableArray = ko.observableArray([bin,int,int,lao]);
2 alert(strObservableArray.indexOf(int));//输出“1”
3 alert(strObservableArray.indexOf(abc));//输出“-1”

2、slice(tart,end)

  The slice function is the observableArray equivalent of the native JavaScript slice function (i.e., it returns the entries of your array from a given start index up to a given end index). CallingmyObservableArray.slice(...) is equivalent to calling the same method on the underlying array (i.e.,myObservableArray().slice(...)).

  参考:

  JavaScript中的slice:https://www.baidu.com/link?url=S9Apxg_qRI5Y30Z4-52aKUe1DECUBMsnPM0vElh1A5dXw_1e56nzL0QGbYSzJoA3vZ__KC4koNo5kUfikHY1U_&wd=&eqid=c39b3d760000e2e60000000455a8b383

  个人理解:slice(tart,end)将返回数组中从start起到end的数组项组成的新数组。

 

  

Konckout学习——observableArray随笔

标签:

原文地址:http://www.cnblogs.com/theo478976804/p/4654816.html

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