上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 34 下一页
摘要: 构造函数可以生成对象。 此构造函数接受一个函数作为参数。 此函数包含两个参数: resolve reject 这两个函数是js内部创建好的,直接用。 resolve 当异步操作成功时,resolve函数被调用 把异步操作的结果作为参数传递给Promise构造函数。 使得Promise对象的状态发生改 阅读全文
posted @ 2020-12-13 16:51 李逍遥701 阅读(354) 评论(0) 推荐(0)
摘要: resolve 解决 reject 拒绝 pending 进行中 fufilled 已成功 indicator 指示器 procedure 程序 handler 处理程序 阅读全文
posted @ 2020-12-13 16:27 李逍遥701 阅读(108) 评论(0) 推荐(0)
摘要: Promise对象 从语法上来说,Promise是一个对象。 对象的三种状态: pending fulfiled rejected 对象的状态不受外界影响,只有异步操作的结果可以改变状态。 对象的状态一旦发生改变,就不会再变化。 对象只有两种状态改变的情况: pending ->fulfiled p 阅读全文
posted @ 2020-12-13 15:13 李逍遥701 阅读(76) 评论(0) 推荐(0)
摘要: 中文方法名:找多个对象。 作用:找到多个对象,返回这些对象组成的数组。 使用格式: 1 let results = arr.filter(function(item, index, array) { 2 // 如果 true item 被 push 到 results,迭代继续 3 // 如果什么都 阅读全文
posted @ 2020-12-13 14:59 李逍遥701 阅读(526) 评论(0) 推荐(0)
摘要: 中文方法名:找到对象索引号 作用:同上。找到就返回索引号,找不到返回-1。 阅读全文
posted @ 2020-12-13 14:52 李逍遥701 阅读(280) 评论(0) 推荐(0)
摘要: 中文方法名:找对象 作用:在对象数组中找想要的对象。 1 let result = arr.find(function(item, index, array) { 2 // 如果返回 true,则返回 item 并停止迭代 3 // 对于假值(falsy)的情况,则返回 undefined 4 }) 阅读全文
posted @ 2020-12-13 14:50 李逍遥701 阅读(2740) 评论(0) 推荐(0)
摘要: const arr = [NaN]; alert( arr.indexOf(NaN) ); // -1(应该为 0,但是严格相等 equality 对 NaN 无效) alert( arr.includes(NaN) );// true(这个结果是对的) 在数组中找寻某个元素时,需要拿“这个元素”和 阅读全文
posted @ 2020-12-13 14:15 李逍遥701 阅读(780) 评论(0) 推荐(0)
摘要: 中文方法名:检查是否包含 作用:同上。找到返回true,找不到返回false。 阅读全文
posted @ 2020-12-13 14:10 李逍遥701 阅读(184) 评论(0) 推荐(0)
摘要: 方法中文名:反向找索引 作用:根据指定的元素和索引号寻找到元素的索引号 1 let arr=[1,2,1,3,4]; 2 console.log(arr.indexOf(1));//0 3 console.log(arr.indexOf(1,1));//2 4 console.log(arr.las 阅读全文
posted @ 2020-12-13 14:08 李逍遥701 阅读(207) 评论(0) 推荐(0)
摘要: 方法中文名:找索引 作用:搜索指定的元素,找到后返回索引号,找不到返回-1。 1 let arr = [1, 0, false]; 2 3 alert( arr.indexOf(0) ); // 1 4 alert( arr.indexOf(false) ); // 2 5 alert( arr.i 阅读全文
posted @ 2020-12-13 13:52 李逍遥701 阅读(259) 评论(0) 推荐(0)
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 34 下一页