es6常见面试题汇总 |
您所在的位置:网站首页 › es6新特性面试题 › es6常见面试题汇总 |
文章目录
一、es6新增了什么?
二、es5和es6的区别,说一下你所知道的es6?
三、var、let、const之间的区别?
四、使用箭头函数应注意什么?
五、介绍下 Set、Map的区别?
六、ES6的模板字符串有哪些新特性?并实现一个类模板字符串的功能?
七、ECMAScript 6 怎么写 class ,为何会出现 class?
八、Promise构造函数是同步执行还是异步执行,那么 then 方法呢?
九、setTimeout、Promise、Async/Await 的区别?
十、promise有几种状态,什么时候会进入catch?
十一、Promise 中reject 和 catch 处理上有什么区别?
十二、forEach、for in、for of三者区别?
十三、Es6解构赋值?
十四、Es6扩展运算符?
十五、Es6中Symbol是什么,有什么作用?
十六、Set是什么,有什么作用?
十七、Map是什么,有什么作用?
十六、谈谈你对深拷贝和浅拷贝的理解?
一、es6新增了什么?
1、块级作用域变量(let和const) let和const关键字可以用来声明块级作用域变量,使得变量只在当前作用域内有效。 { let x = 1; const y = 2; console.log(x); // 1 console.log(y); // 2 } console.log(x); // ReferenceError: x is not defined console.log(y); // ReferenceError: y is not defined2、箭头函数 箭头函数是一种新的函数声明方式,可以更简洁地定义函数。 const add = (x, y) => x + y; console.log(add(1, 2)); // 3 let a = ()=>{ alert(1); } a();3、解构赋值 解构赋值可以用来快速地从数组或对象中提取值并赋给变量。 const arr = [1, 2, 3]; const [a, b, c] = arr; console.log(a, b, c); // 1 2 3 const obj = { x: 1, y: 2, z: 3}; const { x, y, z} = obj; console.log(x, y, z); // 1 2 34、默认参数 函数可以设置默认参数,当调用函数时没有传入该参数时,会使用默认值。 const greet = (name = "World") => `Hello, ${ name}!`; console.log(greet()); // Hello, World! console.log(greet("Alice")); // Hello, Alice!5、模板字符串 模板字符串可以用来更方便地拼接字符串。 const name = "World"; console.log(`Hello, ${ name}!`); // Hello, World!6、扩展运算符 扩展运算符可以用来将数组或对象展开成一系列参数。 const arr1 = [1, |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |