Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

笔记 #26

Open
itboos opened this issue Nov 22, 2018 · 3 comments
Open

笔记 #26

itboos opened this issue Nov 22, 2018 · 3 comments

Comments

@itboos
Copy link
Owner

itboos commented Nov 22, 2018

一些知识的笔记

书: 你不知道的js

   JavaScript       :
    null、undefined、boolean、number、string、object  symbol,
    其中, object 称为引用数据类型, 其它称为简单数据类型

    检测null: 
    由于 typeof null = "object"
    所以使用:
     typeof null === "object" && !null   返回true, 所以可以用这种方式来检查 null
@itboos
Copy link
Owner Author

itboos commented Aug 27, 2019

Promise相关

promise-api#

 // promise allSettled 等待 promise 所有的值,无论是resolve 或者是 rejected。

if(!Promise.allSettled) {
  Promise.allSettled = function(promises) {
    return Promise.all(promises.map(p => Promise.resolve(p).then(value => ({
      state: 'fulfilled',
      value
    }), reason => ({
      state: 'rejected',
      reason
    }))));
  };
}

const p1 = new Promise(resolve => setTimeout(() => resolve(1), 2000))
const p2 = new Promise(resolve => setTimeout(() => resolve(2), 1000))
const p3 = new Promise((resolve, reject) => setTimeout(() => reject('error'), 3000))
Promise.allSettled([p1, p2, p3])
.then(console.log)
// p.resolve 如果传入 promise 对象的情况:
 const p = new Promise((resolve,reject) => setTimeout(() => reject(5), 1000))
// const p = new Promise((resolve,reject) => setTimeout(() => resolve(5), 1000))
const p2 = Promise.resolve(p)
// resolve 如果传的是一个promise, p2的状态将会等待传入的那个promise 决议,
// 如果 p resolve, 则 p2 变成 resolve 状态,否则,变为reject 状态
console.log(p2)// p2 1s 后变为 rejected, value 为5, 同时抛出一个错误。

@itboos
Copy link
Owner Author

itboos commented Nov 15, 2019

@itboos
Copy link
Owner Author

itboos commented Mar 26, 2020

UML知识
UML类图简明教程
设计模式之 UML 类图

在 Java 或其它面向对象设计模式中,类与类之间主要有 6 种关系,他们分别为:依赖,关联,聚合,组合,继承,实现。他们的耦合度依次增强。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant