<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
//注意
//数组,字符串,set,map可以使用for of遍历,因为它们都继承了iterator(迭代器)接口,但是Object不能
// 因为Object没有继承iterator(迭代器)接口,只能使用for in
// let arr = ['a','b','c','d']
// for(let i of arr){
// //for of得到的是值
// console.log(i) // a,b,c,d
// }
// for(let i in arr){
// //for in得到的是键
// console.log(i) // 0,1,2,3
// }
// // 因为Object没有继承iterator(迭代器)接口,只能使用for in
// let obj = {
// 'a': 1,
// 'b': 2,
// 'c': 3
// }
// for(let i in obj){
// //for in得到的是键
// console.log(i)
// }
// for(let i of obj){
// console.log(i) //TypeError: obj is not iterable
// }
// new Promise((resolve, reject) => {
// console.log("1")
// resolve()
// }).then(() => {
// console.log("2")
// new Promise((resolve, reject) => {
// console.log("3")
// resolve()
// }).then(() => {
// console.log("4")
// new Promise((resolve, reject) => {
// console.log("5")
// reject('111')
// })
// })
// }).then(
// () => {
// console.log("6")
// },
// () => {
// console.log("7")
// }
// // console.log("6")
// )
</script>
</body>
</html>
04-18
5887
02-18
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交