JavaScript忍者秘籍笔记

英文不好,英文版是半懂不懂,加上中文版对照,开始啦!!!

2.1 client-side web application 的生命周期概览

  1. page building阶段
    image
  2. Event handling阶段
    image
    单线程模型: only a single piece of code can be executed at once
    事件是异步的: events are asynchronous
    Todo
    3 函数
    3.1 functions are first-class objects
    image
  • Creates a function and assigns a new property to it 有什么用?
var wieldSword = function(){};
wieldSword.swordType = "katana";

3.2 callback function
callback function的使用?

  • SORTING WITH A COMPARATOR

4 理解函数调用
怎么调用函数?
image
this

  1. 方法调用
    image

5 闭包
This chapter covers
■ Using closures to simplify development
■ Tracking the execution of JavaScript programs
with execution contexts
■ Tracking variable scopes with lexical
environments
■ Understanding types of variables
■ Exploring how closures work

How many different scopes can a variable or method
have, and what are they?
Do you know? How are identifiers and their values tracked?
What is a mutable variable, and how do you define one in
JavaScript?

6 promises and generators
This chapter covers
■ Continuing function execution with generators
■ Handling asynchronous tasks with promises
■ Achieving elegant asynchronous code by combining generators and promises

What are some common uses for a generator function?

  1. 全局id 2. 递归dom
    Why are promises better than simple callbacks for asynchronous code?
  2. 回调地狱 2. 完成顺序无法保证
    You start a number of long-running tasks with Promise.race.

When does the promise resolve? When would it fail to resolve?
resolve() reject()

How do you test whether an object has access to a particular property?

Why is a prototype chain important for working with objects in JavaScript?
能够实现继承、代码的重复使用
image

What are some of the benefits of accessing a property’s
value through getters and setters?
数据校验 打印日志 性能测试 空指针 负索引
Do you know? What is the main difference between proxies and getters and setters?
属性值多,getter setter 需要重复编写 proxy 除了可以代理set、get、还有其他的traps
What are proxy traps? Name three types of trap.
get set constructor getPropertyOf apply

What are some of the common pitfalls of using objects as
dictionaries or maps?
What value types can a key/value pair have in a Map?
Must the items in a Set be of the same type?

posted @ 2024-04-17 11:23  躺尸的大笨鸟  阅读(9)  评论(0编辑  收藏  举报