Skip to content

Latest commit

 

History

History
292 lines (258 loc) · 11.4 KB

es6.md

File metadata and controls

292 lines (258 loc) · 11.4 KB
  1. let和const两个关键字与var之间有哪些不同?
  2. 请说明一下const的特点。
  3. 扩展运算符(...)的用途有哪些?
  4. 剩余参数有什么作用?
  5. 什么是解构?
  6. 如果忽略声明关键字,那么在运行对象解构的时候,为何要用圆括号包裹赋值表达式(如下所示)?
({ a, b } = { a: 3, b: 4 });
  1. 如何利用数组解构交换变量?

  2. 执行[, , z] = [1, 2, 3]后,z的值为__________。

  3. 执行[x, ...y] = [1, 2, 3]后,x的值为__________,y的值为__________。

  4. 执行({ a: e, a: f } = { b: 5, a: 6 })后,e的值为__________,f的值为__________。

  5. 执行({ a, b=2 } = { a: 1, b: null })后,b的值为__________。

  6. 什么是模板字面量?

  7. 模板字面量有哪些局限?

  8. ES6是否扩展了对象字面量中的属性名?

  9. 请谈谈你对Symbol的理解。

  10. 如何理解内置符号?

  11. [...[..."..."]].length返回的结果为__________。

  12. 如何导出模块的成员?

  13. 如何导入模块的成员?

  14. 模块的默认值是指什么?

  15. 代码模块化有哪些限制?

  16. Number.isFinite(null)返回的结果为__________。

  17. 请谈谈你对Unicode的理解。

  18. 什么叫Unicode标准化?

  19. "My name is strick".includes("name")返回的结果为__________。

  20. 正则表达式的u标志有什么作用?

  21. 正则表达式的y标志有什么作用?

  22. 如何判断一个字符是由两个编码单元组成的?

  23. Object.is()有什么功能?

  24. 如何使用Object.assign()?

  25. 在ES6中,自有属性的枚举顺序是怎样的?

  26. Array.of()有什么作用?

  27. 使用fill()和copyWithin()需要的注意点有哪些?

  28. find()和indexOf()有哪些区别?

  29. 什么是类型化数组?

  30. 类型化数组与常规数组有哪些异同?

  31. 如何使用DataView?

  32. ES6为函数做了哪些改良?

  33. 函数的length属性有什么作用?

  34. 什么是块级函数?

  35. new.target是由ES6引入的一个元属性,它有何用途?

  36. 箭头函数有哪些注意点?

  37. 箭头函数中的this指向哪里?

  38. 如何理解尾调用优化?

  39. WeakSet和Set有哪些差异?

  40. 如何理解ES6新增的数据结构Map?

  41. 什么是迭代器?

  42. 什么样的对象是可迭代的?

  43. 如何使用for-of循环?

  44. function*用来做什么?

  45. yield关键字有什么作用?

  46. 如何通过生成器实现异步编程?

  47. ES6的类比起用构造函数模拟的类,有哪些独有的特性?

  48. 类有哪些成员?

  49. 当super作为方法使用时,有哪些注意点?

  50. 怎么实现类的继承?

  51. 怎么理解Symbol.species?

  52. 什么是Promise?

  53. Promise包含几种状态?

  54. 如何理解thenable?

  55. Promise.resolve()有什么作用?

  56. 什么是代理?

  57. 什么是反射?它有什么用途?

  58. 执行[1, 2, 3, 4, 5].copyWithin(3, 2)得到的数组为__________。

  59. 如何将Map转换成数组?

  60. yield和return有哪些区别?

  61. 下面代码的输出是什么?

    function sayHi() {
      console.log(name);
      console.log(age);
      var name = "Lydia";
      let age = 21;
    }
    sayHi();
  1. 下面代码的输出是什么?
const shape = {
  radius: 10,
  diameter() {
    return this.radius * 2
  },
  perimeter: () => 2 * Math.PI * this.radius
}

shape.diameter()
shape.perimeter()
  1. 哪个选项是不正确的?
const bird = {
  size: "small"
};
const mouse = {
  name: "Mickey",
  small: true
};

A: mouse.bird.size
B: mouse[bird.size]
C: mouse[bird["size"]]
D: All of them are valid

  1. 下面代码的输出是什么?
let c = { greeting: "Hey!" };
let d;

d = c;
c.greeting = "Hello";
console.log(d.greeting);
  1. 下面代码的输出是什么?
let a = 3;
let b = new Number(3);
let c = 3;

console.log(a == b);
console.log(a === b);
console.log(b === c);
  1. 下面代码的输出是什么?
class Chameleon {
  static colorChange(newColor) {
    this.newColor = newColor;
  }

  constructor({ newColor = "green" } = {}) {
    this.newColor = newColor;
  }
}

const freddie = new Chameleon({ newColor: "purple" });
freddie.colorChange("orange");
  1. 下面代码的输出是什么?
let greeting;
greetign = {};
console.log(greetign);
  1. 下面代码的输出是什么?
function Person(firstName, lastName) {
  this.firstName = firstName;
  this.lastName = lastName;
}

const member = new Person("Lydia", "Hallie");
Person.getFullName = () => this.firstName + this.lastName;

console.log(member.getFullName());
  1. 下面代码的输出是什么?
function getPersonInfo(one, two, three) {
  console.log(one);
  console.log(two);
  console.log(three);
}
const person = "Lydia";
const age = 21;
getPersonInfo`${person} is ${age} years old`;
  1. 下面代码的输出是什么?
function getAge(...args) {
  console.log(typeof args);
}
getAge(21);
  1. 下面代码的输出是什么?
const obj = { 1: "a", 2: "b", 3: "c" };
const set = new Set([1, 2, 3, 4, 5]);

obj.hasOwnProperty("1");
obj.hasOwnProperty(1);
set.has("1");
set.has(1);
  1. 下面代码的输出是什么?
const obj = { a: "one", b: "two", a: "three" };
console.log(obj);
  1. 下面代码的输出是什么?
for (let i = 1; i < 5; i++) {
  if (i === 3) continue;
  console.log(i);
}
  1. 下面代码的输出是什么?
String.prototype.giveLydiaPizza = () => {
  return "Just give Lydia pizza already!";
};
const name = "Lydia";
name.giveLydiaPizza();
  1. 下面代码的输出是什么?
const foo = () => console.log("First");
const bar = () => setTimeout(() => console.log("Second"));
const baz = () => console.log("Third");
bar();
foo();
baz();
  1. 下面代码的输出是什么?
const person = { name: "Lydia" };
function sayHi(age) {
  console.log(`${this.name} is ${age}`);
}
sayHi.call(person, 21);
sayHi.bind(person, 21);
  1. 下面代码的输出是什么?
function sayHi() {
  return (() => 0)();
}
typeof sayHi();
  1. 下面代码的输出是什么?
const numbers = [1, 2, 3];
numbers[10] = 11;
console.log(numbers);
  1. 下面代码的输出是什么?
(() => {
  let x, y;
  try {
    throw new Error();
  } catch (x) {
    (x = 1), (y = 2);
    console.log(x);
  }
  console.log(x);
  console.log(y);
})();
  1. 下面代码的输出是什么?
[[0, 1], [2, 3]].reduce(
  (acc, cur) => {
    return acc.concat(cur);
  },
  [1, 2]
);
  1. 如何实现Promise?
  2. 箭头函数和普通函数有什么区别?
  3. async/await的原理是什么?

思维导图

ES6

参考资料:ES6躬行记