Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

JavaScript ES6新增

 Share


KaiWn

Recommended Posts

      • 命名修饰符
      1. let:不能重复声明变量、块级作用域
      let a = 1;
      let a = 2;
      //报错
      1. const:初始化常量,必须给初始值,否则报错、在同一个作用域内,const定义的常量不能修改其值、块级作用域
      const a = 10
      a = 100
      //报错,不能重复声明
      • 解构
      const obj = {
      name:'jack'
      age:18
      sex:'男'
      }
      let{name,age,sex} = obj
      • 箭头函数
      let i = (a) =>{
      console.log(a*2)
      }
      i(2)//4
      let j = (b) => console.log(b+3)
      j(2)//5
      • 扩展运算符
      var arr = [1,2,3]
      var arr1 = [4,5,6]
      var arr2 = arr.concat(...arr1)
      //输出arr2为[1,2,3,4,5,6]
      //扩展运算符(...)会将数组或者对象打开,直接打印的话中间的逗号会省略,但是需要用逗号时会自动加上之间的逗号
      • 字符串新增
      var str = 'abc'
      console.log(str.includes('a'))//true
      //includes 是否包含,包含返回true否则返回false
      var str = 'javascript'
      console.log(str.startsWith('j'))//true
      //startsWith 是否以括号中的内容开头,是的话返回true,否则返回false
      console.log(str.endsWith('j'))//false
      //endsWith 是否以括号中的内容结尾,是就返回true否则返回false
      var str = 'abc'
      console.log(str.repeat(3))
      //'abcabcabc'
      // repeat 平铺,括号中的参数为平铺次数
      • 数组新增
      Array.from() 将伪数组转为数组
      Array.of() 将一系列的值转为数组
      Array.find() 查找元素 返回对应匹配的第一个元素
      Array.findIndex() 查找下标 返回对应第一个匹配的下标
      • Object的方法
      keys 获取对象的所有的key
      values 获取对象的所有的值
      entries 获取对象所有的键值对象(数组)
      Object.is 判断俩个对象是否是一个
      Object.assign() 将后面的内容拷贝给第一个(浅拷贝)
      • class 类
      1. class类名首字母必须大写,其中要使用this关键词的话前面必须加上constructor(构造器)
      2. 继承(extends)可以继承父类里面所有非私有属性及方法,但是必须要加上super()
      • 基本数据类型
      1. BigInt 大整型,一般的number类型只能存储32位,大整型在此基础上加强,加大容量,原理是根据字符串来实现
      2. Symbol 唯一,一般用做数组的key
Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...