1.箭头函数var my_func res console.log(这是一个函数${res}) my_func(123) 这是一个函数123var my_list [1,2,3,4,]; my_list.forEach(res console.log(res))2.异步promisefunction simple_promise(){ //创建一个promise对象,在创建promise对象时需要手动创建回调函数 //在创建回调函数过程中需要传递两个固定参数resolve reject /** * 一个promise任务内部维护了3种状态pending-fulfilled-reject * resolve: promise对象成功时调用的函数可以更改promise对象的状态pending-fulfilled 调用resolve方法的时候可以传递一个值这个值会作为then方法中回调函数的参数 * reject: promise对象失败时调用的函数可以更改promise对象的状态pending-reject 调用reject时可以传递一个错误信息这个信息作为catch方法中回调函数的参数 */ var promise new Promise(function (resolve, reject) { // 模拟异步任务 var success false; if(success){ resolve(异步任务已完成); }else{ reject(异步任务失败); } }) return promise; } var promise_obj simple_promise(); console.log(promise_obj) promise_obj.then(function (res){ console.log(res) }).catch(function (res) { console.log(res) }) Promise { rejected 异步任务失败 } 异步任务失败3.promise任务的链式调用function step_1(){ return new Promise(function (resolve, reject) { console.log(第一步完成...) resolve(result:step_1) }); } function step_2(){ return new Promise(function (resolve, reject) { console.log(第二步完成...) resolve(result:step_2) }); } function step_3(){ return new Promise(function (resolve, reject) { console.log(第三步完成...) resolve(result:step_3) }); } step_1().then(step_2).then(step_3).then(function (result) { console.log(result) }) 第一步完成... 第二步完成... 第三步完成... result:step_34.js中声明数组的两种方式4.1 字面量声明var arr [1,2,3]4.2 通过对象创建数组var arr new Array(1,2,3)4.3 数组操作arr.push(5) //在数组结尾添加元素 arr.pop() //弹出数组中最后一个元素 arr.unshift(0) //在数组开头添加元素 arr.shift() //弹出数组开头的元素5.创建对象的4种方式5.1 通过字面量创建对象var stu_info { name : admin, age : 18, print_info : function (){ console.log(姓名${this.name} 年龄:${this.age}) } } stu_info.print_info();5.2 通过函数创建对象function create_student(name, age){ this.name name; this.age age; this.print_info function (){ console.log(姓名${this.name} 年龄:${this.age}) } } var stu1 new create_student(张三, 18); var stu2 new create_student(李四, 25); stu1.print_info(); stu2.print_info();5.3 通过new Object 创建对象var stu3 new Object() stu3.name 王五; stu3.age 30; stu3.print_info function(){ console.log(姓名${this.name} 年龄:${this.age}) } stu3.print_info()5.4 通过类创建对象class Student{ constructor(name, age) { this.name name; this.age age; } print_info(){ console.log(姓名${this.name} 年龄:${this.age}) } } var stu4 new Student(小红, 19); stu4.print_info();