提交 e3e69105 编写于 作者: 杜庆泉's avatar 杜庆泉

完善 index/lastIndexOf 示例

上级 e8f82c83
......@@ -168,6 +168,14 @@ export function testArray(): Result {
expect(array2.includes('c', 100)).toEqual(false);
})
test("indexOf", () => {
let raw = {}
let arr = new Array()
arr.push({});
arr.push({});
arr.push(raw);
expect(arr.indexOf(raw)).toEqual(2);
const beasts: string[] = ['ant', 'bison', 'camel', 'duck', 'bison'];
expect(beasts.indexOf('bison')).toEqual(1);
expect(beasts.indexOf('bison', 2)).toEqual(4);
......@@ -191,6 +199,15 @@ export function testArray(): Result {
expect(elements.join('-')).toEqual("Fire-Air-Water");
})
test("lastIndexOf", () => {
let raw = {}
let arr = new Array()
arr.push({});
arr.push({});
arr.push(raw);
expect(arr.lastIndexOf(raw)).toEqual(2);
const animals: string[] = ['Dodo', 'Tiger', 'Penguin', 'Dodo'];
expect(animals.lastIndexOf('Dodo')).toEqual(3);
expect(animals.lastIndexOf('Tiger')).toEqual(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册