
es6
qq_58590962
这个作者很懒,什么都没留下…
展开
-
静态属性和静态方法
静态方法和静态属性:由类来直接使用,不能通过实例化对象来调用作用:1.封装性 (类.方法) // static关键字 class People { static len = 10 //静态属性 static创建的 constructor(name) { this.name = name } shoInfo() { console.log(this.name);原创 2021-06-26 21:16:25 · 156 阅读 · 0 评论 -
面向对象编程class类
class类:es6之前js用构造函数的方式来进行对象的创建,其他语言都具有类这个概念以及对应的类型es6之后 引入class 类// es6之前构造函数定义 function People(name, age) { //构造函数 类 this.name = name this.age = age } People.prototype.showInfo = function () { console.log(this.name);原创 2021-06-26 15:45:04 · 148 阅读 · 0 评论 -
es6中新增的数据类型
map类型:map类型:js中的对象的一个更新,对象本质 键值对 key:value 原始对象中key只能为字符串 map类型:其他数据类型的数据 也可以作为key<body> <button id="bt1"></button></body><script> let bt1 = document.getElementById("bt1") let m1 = new Map() //创建m1对象 //原创 2021-06-26 14:40:37 · 424 阅读 · 0 评论 -
ES6中字符串新增的方法
repeat重复 repeat(次数) 返回一个新的字符串 let str = "hello world" let result = str.repeat(3) console.log(result); //hello worldhello worldhello worldincludes判断是否含有指定子串 返回T或F let str = "hello world" let result = str.includes("hello") console.l原创 2021-06-26 13:47:37 · 66 阅读 · 0 评论 -
ES6中数组新增的方法
forEach:用于遍历数组数组.forEach(function(item,index){}) // 传统for循环遍历 let arr1 = [1, 2, 3] for (i = 0; i < arr1.length; i++) { console.log(arr1[i]); //123 } //Es6的forEach遍历 let arr2 = [1, 2, 3] arr2.forEach((item, index) =>原创 2021-06-25 11:32:49 · 293 阅读 · 0 评论 -
ES6参数默认值与rest参数
参数默认值:ES6新增默认参数功能,参数可以有默认值(初始值),通常有默认值的写在最后 // 解构 let obj = { host: "192.168.1.1", username: "王一", password: 123456, } function connect({ host, username, password, port = 3006 }) { //port=3006 设置参数默认值 console原创 2021-06-21 13:39:37 · 113 阅读 · 0 评论 -
ES6中的箭头函数
箭头函数对比传统函数: // 传统js中的函数 function showName1() { console.log("name1"); } // 箭头函数 let showName2 = () => { console.log("name2"); } showName1();//name1 showName2();//name2区别一:传统js中的函数,存在变量的默认提升箭头函数:由let定义,不存在变原创 2021-06-20 23:59:58 · 84 阅读 · 0 评论 -
ES6中对象的简写方式
没学ES6之前我们通常的写法: let obj = { name: "wangyi", //key:value age: 21, showInfo: function () { console.log(this.name); } }ES6中对象的简写方式如果key和value相同,那么直接写一个就可以 let name = "wangyi"; let age = 21; let o原创 2021-06-20 22:43:55 · 299 阅读 · 0 评论