• javaScript
      • 变量
        • let
        • const
        • var
      • 注释
        • // 单行注释
        • /多行注释/
      • 运算符
        • 位运算符
        • 赋值运算符
          • var age = 18, address = “张家界”, gz = 2000;
          • = += -= *= %=
          • var [x,y,z] = [‘hello’, ‘JavaScript’, ‘ES6’];
            console.log(x,y,z); // hello JavaScript ES6
          • var person = {
            name: ‘小明’,
            age: 20,
            gender: ‘male’,
            passport: ‘G-12345678’,
            school: ‘No.4 middle school’
            };
            var {name, age, passport} = person;
          • var x=1, y=2;
            [x, y] = [y, x]
        • 算术运算符

          • ```
      • / %

        1. - 逻辑运算符
        2. - && ||
        3. - 布尔运算符
        4. > = < <=
        5. - NaN === NaN; // false
        6. - == ===
        7. - ==
        8. ```javascript
        9. 先检查两个操作数的数据类型是否相同
        10. 如果相同,则比较两个数是否相等
        11. 如果不同,则先将两个数转换为相同数据类型,再进行比较
        1. 先检查两个操作数的数据类型是否相同
        2. 若不同,直接返回false
        3. 若相同,则比较二者是否相等
        • ===
          • 条件运算符
          • 1>2? “正确”:”错误”;
      • 数据类型
        • 数据种类
          • Null
          • Undefined
          • NaN
          • Number
          • String
            • 多行 字符串
            • 格式化
              • var name = ‘明明’;
                var message = 你好,${name };
                console.log(message);
            • 方法
              • 获取长度
                • message.length;
              • 索引字符
                • message[0]
              • 获取字符位置
                • message.indexOf(“你”);
              • 根据区间索引字符
                • message.substring(0, 3)
          • Bool
          • Array
            • 创建
              • [1, 2, 3.14, ‘Hello’, null, true]
            • 更改长度
              • arr.length=2; // [ 1, 2 ]
              • arr.length=8; // [ 1, 2, 3.14, ‘Hello’, null, true, <2 empty items> ]
            • 更改元素
              • arr[0] = 99; //[ 99, 2, 3.14, ‘Hello’, null, true ]
            • 方法
              • 索引位置
                • arr.indexOf(99) // 0
              • 切片
                • arr.slice(0, 3) // [ 99, 2, 3.14 ]
                  arr.slice(3) // [ ‘Hello’, null, true ] arr.slice() // 复制
              • 添加元素
                • unshift
                • push
              • 删除元素
                • shift
                • pop
              • 排序
                • arr.sort();
                • arr.reverse();
              • 同时添加和删除
                • var array = [‘Microsoft’, ‘Apple’, ‘Yahoo’, ‘AOL’, ‘Excite’, ‘Oracle’];

    var org = array.splice(2, 3, “Google”, “Facebook”);

    console.log(org); //[ ‘Yahoo’, ‘AOL’, ‘Excite’ ]

    console.log(array); //[ ‘Microsoft’, ‘Apple’, ‘Google’, ‘Facebook’, ‘Oracle’ ]

    var onlyDel = array.splice(2, 2);

    console.log(onlyDel); // [ ‘Google’, ‘Facebook’ ]

    var onlyAdd = arr.splice(2, 0, “Google”, “FackBook”);

    console.log(onlyAdd); // []

    console.log(array);

    1. - concat
    2. - var arr = ["A", "B", "C"];

    var added = arr.concat([1, 2, 3]);
    console.log(added); // [ ‘A’, ‘B’, ‘C’, 1, 2, 3 ]

    1. - join
    2. - var arr = ['A', 'B', 'C', 1, 2, 3];

    console.log(arr.join(“—-“)); // A—-B—-C—-1—-2—-3

    1. - Obj
    2. - 创建
    3. - var xiaoming = {
    4. name: '小明',
    5. birth: 1990,
    6. school: 'No.1 Middle School',
    7. height: 1.70,
    8. weight: 65,
    9. score: null

    };

    1. - 获取属性
    2. - xiaoming.name
    3. - 添加属性
    4. - xiaoming.hibbit = "吃零食";
    5. - 删除属性
    6. - delete xiaoming.age
    7. - 检查属性是否存在
    8. - 'age' in xiaoming
    9. - map
    10. - var m = new Map([['Michael', 95], ['Bob', 75], ['Tracy', 85]]);

    console.log(m.get(‘Bob’));
    -
    var map = new Map();
    map.set(“adam”,67);
    console.log(map); // Map { ‘adam’ => 67 }
    console.log(map.has(“adam”)); //true
    map.delete(“adam”);
    console.log(map); //Map {}

    1. - set
    2. - var set = new Set([1,2,3,3]);

    console.log(set); // Set { 1, 2, 3 }
    set.add(4);
    console.log(set); // Set { 1, 2, 3, 4 }
    set.delete(4);
    console.log(set);

    1. - 类型判断
    2. - typeof //确定类型
    3. - instanceof //判断类型
    4. - 类型转换
    5. - obj.toString()
    6. - parseInt(obj) parseFloat(obj) // 传入进制参数可以进行进制转换
    7. - 流程控制
    8. - 条件分支
    9. - if
    10. - if else
    11. - if else if else
    12. - 循环
    13. - for
    14. - for (i=0; i<arr.length; i++) {
    15. do......something

    }
    - var x = 0;
    for (;;){
    if (x > 100) {
    break;
    }
    x++;
    console.log(x)
    }
    - for(var key in obj){
    do……something
    }
    - var array = [1, 2, 3];
    for(var element of array){
    console.log(element)
    }
    - var array = [“A”,”B”,”C”];
    array.forEach(function (element,index,array) {
    console.log(element + ‘, index = ‘ + index,’array=’+array);
    });

    1. - while
    2. - while
    3. - do while
    4. - switch
    5. - var BLUE = "blue", RED = "red", GREEN = "green";

    var sColor = BLUE;
    switch (sColor) {
    case BLUE: alert(“Blue”);
    break;…

    1. - 函数
    2. - 自定义
    3. - function abs1(x) {
    4. if (x > 0) {
    5. return x;
    6. } else {
    7. return -x;
    8. }

    }

    1. - var abs2 = function (x) {
    2. if (x >= 0) {
    3. return x;
    4. } else {
    5. return -x;
    6. }

    };
    - 子主题 3

    1. - arguments
    2. - function foo(x) {
    3. console.log(`x=` + x);
    4. for (var i = 0; i < arguments.length; i++) {
    5. console.log(arguments[i])
    6. }

    }

    1. - rest
    2. - function restDemo(a, b, ...rest) {
    3. console.log(rest)

    }

    restDemo(1, 2, 3, 4, 5); //[ 3, 4, 5, 6, 7 ]

    1. - 方法(对象中)
    2. - function(){ }
    3. - this指向
    4. - function getAge() {
    5. const y = new Date().getFullYear();
    6. return y - this.birth;

    }
    var xiaoming = {
    name: ‘小明’,
    birth: 1990,
    age: getAge
    };
    console.log(getAge.apply(xiaoming,[]));
    console.log(getAge.call(xiaoming));
    // apply会参数打包成数组

    1. - 装饰器
    2. - 高阶函数
    3. - 自定义
    4. - var heighfunc = function (x, y, f) {
    5. return f(x) + f(y)

    };
    var f = function (n) {
    return n * n;

    };
    console.log(heighfunc(5, 6, f));

    1. - 内部
    2. - map
    3. - var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];

    var results = arr.map(pow);
    console.log(results);

    1. - reduce
    2. - var array = [1,3,5,7,9];

    console.log(array.reduce(function (x, y) {
    return x + y;
    }));

    1. - filter
    2. - var array = [1, 2, 4, 5, 6, 9, 10, 15];

    var r = array.filter(function (x) {
    return x % 2 === 0;
    });
    console.log(r);

    1. - sort
    2. - var array = [10, 20, 30];

    array.sort(function (x, y) {
    if (x > y) {
    return -1;
    } else {
    return 1;
    }
    });
    console.log(array);

    1. - every
    2. - var arr = ['Apple', 'pear', 'orange'];

    console.log(arr.every(function (s) {
    return s.length > 0;
    })); // true, 因为每个元素都满足s.length>0

    1. - find
    2. - var arr = ['Apple', 'pear', 'orange'];

    console.log(arr.find(function (s) {
    return s.toLowerCase() === s;
    })); // ‘pear’, 因为pear全部是小写

    1. - findIndex
    2. - var arr = ['Apple', 'pear', 'orange'];

    console.log(arr.findIndex(function (s) {
    return s.toLowerCase() === s;
    })); // 1, 因为’pear’的索引是1

    1. - forEach
    2. - var arr = ['Apple', 'pear', 'orange'];

    arr.forEach(console.log);

    1. - 闭包
    2. - var iBaseNum = 10;

    function addNum(iNum1, iNum2) {
    function doAdd() {
    return iNum1 + iNum2 + iBaseNum;
    }
    return doAdd();
    } // doAdd() 函数根本不接受参数,它使用的值是从执行环境中获取的

    1. - 箭头函数
    2. - var fn = x => x * x;
    3. - 生成器
    4. - function*gener() {
    5. for (let i = 0; i < 100; i++) {
    6. yield i;
    7. }

    }
    var gen = gener();
    console.log(gen.next());
    console.log(gen.next());
    console.log(gen.next().value);
    - function fib(max) {
    var
    t,
    a = 0,
    b = 1,
    arr = [0, 1];
    while (arr.length < max) {
    [a, b] = [b, a + b];
    arr.push(b);
    }
    return arr;
    }

    1. - 作用域
    2. - 就近原则
    3. - 内层函数变量
    4. - 嵌套层变量
    5. - 函数外变量
    6. - 标准对象
    7. - 包装对象
    8. - var n = new Number(123); // 123,生成了新的包装类型

    var b = new Boolean(true); // true,生成了新的包装类型
    var s = new String(‘str’); // ‘str’,生成了新的包装类型

    1. - Date
    2. - RegExp
    3. - Json
    4. - JSON.stringify(obj)
    5. - JSON.parse(“text”)
    6. - 面向对象
    7. - 原型
    8. - class
    9. - class Student {
    10. constructor(name) {
    11. this.name = name;
    12. }
    13. hello() {
    14. console.log('Hello,' + this.name + '!')
    15. }

    }
    var student = new Student(“小明”);
    student.hello();

    class PrimaryStudent extends Student {
    constructor(name, grade) {
    super(name);
    this.grade = grade;
    }
    myGrade() {
    console.log(“I am grade” + this.grade);
    }
    }
    var primaryStudent = new PrimaryStudent(“小明”,”31”);
    primaryStudent.hello();
    primaryStudent.myGrade();

    1. - 浏览器对象
    2. - alert("弹窗测试")
    3. - prompt("请输入你的年龄")
    4. - confirm(“确认框测试”)
    5. - window
    6. - navigator
    7. - screen
    8. - location
    9. - document
    10. - 文档对象
    11. - 异常处理
    12. - try ... catch
    13. - try ... catch ... finally
    14. - throw
    15. - 包管理工具