Konckout学习——observableArray随笔

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的数组项组成的新数组。

 

  

转载于:https://www.cnblogs.com/theo478976804/p/4654816.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值