{__ob__: Observer} startTime : "13:0:0" stopTime : "14:0:0"} 判断这个对象在0 : startTime : "13:0:0" stopTime : "14:0:0" __ob__ : Observer {value: {…}, shallow: false, mock: false, dep: Dep, vmCount: 0} get startTime : ƒ reactiveGetter() set startTime : ƒ reactiveSetter(newVal) get stopTime : ƒ reactiveGetter() set stopTime : ƒ reactiveSetter(newVal) [[Prototype]] : Object 1 : startTime : "16:0:0" stopTime : "17:0:0" __ob__ : Observer {value: {…}, shallow: false, mock: false, dep: Dep, vmCount: 0} get startTime : ƒ reactiveGetter() set startTime : ƒ reactiveSetter(newVal) get stopTime : ƒ reactiveGetter() set stopTime : ƒ reactiveSetter(newVal) [[Prototype]] : Object 2 : startTime : "16:0:0" stopTime : "0:0:0" __ob__ : Observer {value: {…}, shallow: false, mock: false, dep: Dep, vmCount: 0} get startTime : ƒ reactiveGetter() set startTime : ƒ reactiveSetter(newVal) get stopTime : ƒ reactiveGetter() set stopTime : ƒ reactiveSetter(newVal) [[Prototype]] : Object 3 : startTime : "16:22:58" stopTime : "19:22:58" 在这个数组中的处在第几个,代码怎么写
时间: 2023-12-14 12:37:25 浏览: 141
Observer模式代码实现
这个数组中的对象处于第4个位置,可以使用数组的indexOf方法来查找该对象在数组中的位置,代码如下:
```
const arr = [
{startTime: "13:0:0", stopTime: "14:0:0", __ob__: Observer},
{startTime: "16:0:0", stopTime: "17:0:0", __ob__: Observer},
{startTime: "16:0:0", stopTime: "0:0:0", __ob__: Observer},
{startTime: "16:22:58", stopTime: "19:22:58", __ob__: Observer}
];
const obj = {startTime: "16:22:58", stopTime: "19:22:58", __ob__: Observer};
const index = arr.indexOf(obj);
console.log(index); // 输出3
```
阅读全文