1. let声明—-let a=123

      1. let demo = (a) => {
      2. console.log(a);
      3. }
      4. demo(123)
      5. //123
      1. 没有变量提升—必须先声明,再使用
      2. 不可重复定义—重复声明报错
      3. 块级作用域—-如:if(){},for(){},function(){}这样的代码块
    2. 箭头函数—-let demo=(x,y)=>{ }

      1. 语法改变,从function (){ }——->()=>{ }
      2. 如果函数只有一个参数可以省略括号()

        1. let demo = a => {
        2. console.log(a);
        3. }
        4. demo(123)
        5. //123
      3. 如果函数只有一个参数且执行语句只有一条可省略{ }花括号

        1. let demo = a => console.log(a);
        2. demo(123)
      4. this指向问题

        1. 旧函数:谁调用this指向谁,而箭头函数是创建时就确定了this指向

          1. function fun() {
          2. let demo = () => {
          3. console.log(this);
          4. }
          5. demo()
          6. }
          7. let obj2 = {
          8. user: 111,
          9. pwd: 222,
          10. fun: fun
          11. }
          12. obj2.fun()
          13. //{user: 111, pwd: 222, fun: ƒ}
          14. //this指向fun(),fun的this指向的obj2
          1. function fun() {
          2. console.log(this);
          3. }
          4. let obj = {
          5. name: 123,
          6. sex: 'nv',
          7. fun: fun
          8. }
          9. obj.fun()
          10. //{name: 123, sex: 'nv', fun: ƒ}
          11. //this指向obj
          1. let demo = () => {
          2. console.log(this);
          3. }
          4. let obj = {
          5. name: 123,
          6. sex: 'nv',
          7. demo: demo
          8. }
          9. obj.demo()
          10. //Window {window: Window, self: Window, document: document, name: '', location: Location, …}
          11. //指向window
        2. 不可通过call( ),apply( )更改this指向

          1. let demo = () => {
          2. console.log(this);
          3. }
          4. let obj2 = {
          5. user: 111,
          6. pwd: 222,
          7. fun: fun
          8. }
          9. demo.call(obj2)
          10. //指向window
          1. let demo = () => {
          2. console.log(this);
          3. }
          4. let obj2 = {
          5. user: 111,
          6. pwd: 222,
          7. fun: fun
          8. }
          9. demo.apply(obj2)
          10. //指向window
        3. 1

        4. 2
        5. 3
    3. 模板字符串

      1. 旧时拼接

        1. let str1 = 123
        2. let str2 = str1 + 'xiaoming'
        3. console.log(str2);
        4. //123xioaming
      2. ES6拼接

        1. let str1 = 123
        2. let str2 = `${str1}xioaming`
        3. console.log(str2);
        4. //123xioaming
    4. class类——就是一个语法糖

      1. 定义

        1. class stu1{
        2. constructor(name,sex){
        3. this.name=name
        4. this.sex=sex
        5. this.grade=function () {
        6. console.log(123)
        7. }
        8. }
        9. mood(){
        10. console.log(234)
        11. }
        12. }
        13. let class1=new stu1('xiaoming','男')
      2. 静态属性和静态方法——-该方法不能通过实例调用/

        1. class stu1 {
        2. constructor(name, sex) {
        3. this.name = name
        4. this.sex = sex
        5. this.grade = function () {
        6. console.log(123)
        7. }
        8. }
        9. mood() {
        10. console.log(234)
        11. }
        12. //静态方法
        13. static getXingGe() {
        14. console.log('性格')
        15. }
        16. //静态属性
        17. static name='女'
        18. }
        19. let class1 = new stu1('xiaoming', '男')
        20. console.log(class1);
        21. class1.mood()
        22. // class1.getXingGe()---//class1.getXingGe is not a function
        23. stu1.getXingGe()//只能通过类名调用,不能通过实例对象调用
      3. class类继承image.png

      4. 私有属性和私有方法
    5. for…of循环
      1. for…in循环

    image.png

    1. for…of循环