- 博客(4)
- 收藏
- 关注
原创 javascript中async/await详解
async,await async是Generator的语法糖,异步编程的终极解决方案,彻底解决回调地狱的问题 async用来声明一个function是异步的,而await用来等待一个异步函数的执行 注意: await只能出现在async函数里面 async async function asyncfunc() { return '奥里给' } const result = asyncfunc() console.log(result) // Promise result.then((val)=&g
2020-08-25 17:47:10
4427
原创 for循环与setTimeout结合面试问题巩固
for循环与setTimeout 先来一个经典的面试题 for(var i = 0; i < 5; i += 1) { setTimeout(function() { console.log(i) }, 1000) } 最终的结果会是多少? 一秒后... 5 5 5 5 5 问题 1. 为什么输出的是5 2. 为什么输出的全部都是5 3. 为什么定时器是一秒后全部都输出,而不是每过一秒钟输出一个 解答 1. 为什么是5 因为使
2020-07-15 16:39:22
258
原创 JavaScript中常用字符串对象汇总
JavaScript中常用字符串对象汇总 1. 字符方法 ① charAt() str.charAt(index) charAt() 返回指定位置的字符 var str = "HELLO WORLD"; var n = str.charAt(2) consoel.log(n) // L ② charCodeAt() str.charCodeAt(index) charCodeAt() 返回在指定的位置的字符的 Unicode 编码 var str = "HELLO WORLD"; var n = str
2020-06-05 09:44:49
259
原创 JavaScript中常用数组对象汇总
总结JS中常用数组对象 1. 检测方法 ① isArray() 用来判断此变量是否为数组 返回boolean值 let arr = '字符串' let arr2 = ['数组'] console.log(arr.isArray()) // false console.log(arr2.isArray()) // true 2. 转换方法 ① toString() arr.toString() toString() 把对象转换成字符串并返回 let arr = [1,2,3,4,5] let num =
2020-06-04 10:20:08
652
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人