上一页 1 2 3 4 5 6 7 8 9 10 ··· 44 下一页
摘要: 介绍 ES6 提供了 Map 数据结构。它类似于对象,也是键值对的集合。但是“键的范围不限于字符串,各种类型的值(包括对象) 都可以当作键。Map 也实现了 iterator 接口,所以可以使用[扩展运算符]和 [for...of...] 进行遍历。Map的属性和方法: 1.size 返回Map的元 阅读全文
posted @ 2023-02-20 10:28 罗砂 阅读(26) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>set集合实践</title> </head> <body> <div id="ad"> </div> <div></div> <script> let arr 阅读全文
posted @ 2023-02-20 10:07 罗砂 阅读(21) 评论(0) 推荐(0)
摘要: set方法可以去重数组 // 声明一个set let e = new Set() let ess = new Set(['张三','李四','王五','李四']) console.log(ess); 寻找元素个数 console.log(ess.size); 添加新的元素 ess.add('赵六') 阅读全文
posted @ 2023-02-20 09:38 罗砂 阅读(32) 评论(0) 推荐(0)
摘要: 调用then方法 then方法返回结果是Promise对象,对象状态由回调函数的执行结果决定 如果回调函数中返回的结果是非promise类型的属性,状态为成功,返回值为对象的成功 then方法是可以只指定一个回调的 <script> // 创建Promise对象 const p =new Promi 阅读全文
posted @ 2023-02-20 09:00 罗砂 阅读(226) 评论(0) 推荐(0)
摘要: 使用表格制作 解释都在注释里 html文件: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>she</title> <link rel="stylesheet" href="./index.css"> </head> <bod 阅读全文
posted @ 2023-02-15 10:03 罗砂 阅读(46) 评论(0) 推荐(0)
摘要: 复制可用 // 接口地址:http://poetry.apiopen.top/sentences (随机获取一句诗词) // 新建一个Promise对象 const Pro = new Promise((resolve, reject) => { // 1.创建对象 const xhr = new 阅读全文
posted @ 2023-02-11 09:51 罗砂 阅读(74) 评论(0) 推荐(0)
摘要: // 1.引入fs模块 const fs = require('fs') // 2.调用方法读取文件 fs.readFile('./ES6/CCTV.md',(err,data)=>{ // 如果失败,则抛出错误 if(err) throw err; // 如果没有出错,则输入内容 console. 阅读全文
posted @ 2023-02-10 16:51 罗砂 阅读(36) 评论(0) 推荐(0)
摘要: 介绍 Promise是ES6引入的异步编程的新解决方案,语法上Promise是一个构造函数, 用来封装一步操作并可以获取其成功或失败的结果。 1.Promise构造函数:Promise(excutor){ } 2.Promise.Prototype.then方法 3.Promise.prototyp 阅读全文
posted @ 2023-02-10 15:05 罗砂 阅读(137) 评论(0) 推荐(0)
摘要: 介绍 生成器函数是ES6提供的一种异步编程解决方案,语法行为与传统函数完全不同 function * gen{ yiwld '一只没有耳朵'; yiwld'一只没有尾巴' } 生成器函数其实就是一个特殊的函数 异步编程 之前的都是纯回调函数进行异步 创建这个函数的方法 function * gen( 阅读全文
posted @ 2023-02-10 14:25 罗砂 阅读(47) 评论(0) 推荐(0)
摘要: 介绍 迭代器(iterator)是一种接口,为各种不同的数据结构提供统一的访问机制。 任何数据结构只要部署iterator借口,就可以完成遍历操作。 1.ES6创造了一种新的遍历命令for...of循环,ierator接口主要供for...of消费 2.原生具备iterator借口的数据(可用for 阅读全文
posted @ 2023-02-10 11:44 罗砂 阅读(27) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 44 下一页