1 | git clone -b 'vue(v2)' http://192.168.251.11/yanchangyong/workflow-web.git |
mac say
js array loop
1 | let i = 0; |
1 | let i = 0; |
1 | for (let i = 0; i < scores.length; i++) { |
1 | for (i in scores) { |
1 | for (score of scores) { |
forEach
map
reduce
reduceRight
flatMap
filter
every
some
indexOf
lastIndexOf
find
findIndex
keys
entries
includes
Spread …
via https://www.w3schools.com/js/js_array_iteration.asp
via https://www.w3schools.com/jsref/jsref_obj_array.asp
at
1 | const fruits = ["Banana", "Orange", "Apple", "Mango"]; |
array.slice(start, end)
The slice() method does not change the original array.
array.splice(index, howmany, item1, ….., itemX)
The splice() method overwrites the original array.
copyWithin
array.copyWithin(target, start, end)
sublime console.log
Tools -> Developer -> New Snippet…
1 | <snippet> |
保存为 log.sublime-snippet
使用:
log+回车
ts 笔记
npm –save 和–save-dev的区别
使用–save 安装的包是项目发布之后还需要依赖的包, 如axiox , express等包,等项目上线以后还需使用。
使用–save-dev 安装的包则是开发时依赖的包,等项目上线则不会使。
npm install 和 npm i 是一样
–save 和 -S 是一样
–save-dev 和 -D 是一样的
tsc
1 | npm i tsc -D |
任何 1.ts 生成 1.js
也可以修改 tsconfig.json 配置
1 | // "outFile":"./", |
类型
boolean
number
string
Explicit
Implicit
1 | let firstName: string = "Dylan"; |
unknown 比 any 安全
1 | let w: unknown = 1; |
date 性能
1 | Date.now() // 最快 |
via https://www.measurethat.net/Benchmarks/Show/9412/0/new-date-vs-new-dategettime-vs-datenow-100k
interface 和 type 区别
- 接口是通过继承的方式来扩展,类型别名是通过 & 来扩展。
- 接口可以自动合并,而类型别名不行
https://zhuanlan.zhihu.com/p/351213183
到底应该用 type 还是 interface ?
Because an interface more closely maps how JavaScript objects work by being open to extension, we recommend using an interface over a type alias when possible.
On the other hand, if you can’t express some shape with an interface and you need to use a union or tuple type, type aliases are usually the way to go.
意思是说能用 interface 的地方就用 interface,否则用 type,其实这个解释官方说的也比较明确,这样使用的原因是因为更贴合 JavaScript 对象的工作方式,再清晰一些,如果我们是定义一个 object,那么最好是使用 interface 去做类型声明,什么时候用 type 呢,当定义一个 function 的时候,用 type 会更好一些
1 | // the `?` operator here marks parameter `c` as optional |
1 | class Person { |
class Property ‘’ has no initializer and is not definitely assigned in the constructor
- tsconfig.json 关掉严格
1 | "compilerOptions": { |
- undefined
1 | employees : Employee[] | undefined; |
- definite assignment assertion
1 | employees!: Employee[]; |
- init
1 | employees: Employee[] = []; |
- Assignment in the Constructor
employees: Employee[];
constructor() {
this.employees=[];
}
super
父级构造函数
?? 对比 ||
使用 ?? 时,只有当值1为null或undefined时才返回值2;
使用 || 时,值1会转换为布尔值判断,为true返回值1,false 返回值2
js event button
0: Main button pressed, usually the left button or the un-initialized state
1: Auxiliary button pressed, usually the wheel button or the middle button (if present)
2: Secondary button pressed, usually the right button
3: Fourth button, typically the Browser Back button
4: Fifth button, typically the Browser Forward button
move sub folder files outside to parent
下载的美剧是1目录1集,想考出来
即
a1/a1.mp4
a2/a2.mp4
->
a1.mp4
a2.mp4
1 | find . -type f -exec mv {} ./ \; |
报错!重名!
a1.mp4/a1.mp4
a2.mp4/a2.mp4
1 | find . -type f -exec mv {} ../ \; |
那就往上一层(然后删除空目录,再考回去)
chrome console 调试主题 prefers-color-scheme
command+shift+p (mac)运行
show rendering
== 或者
- 或者 右侧 … 里 more tools 都有 rendering
里面可以切换 黑白主题
hello 2023
hi
vscode theme 2022
数据来源:
https://data.cdc.gov/NCHS/Provisional-COVID-19-Deaths-by-Sex-and-Age/9bhg-hcku
temp1 是第一个 td(Age Group)
1 | var td = $(temp1); |
美国 covid 死亡人数
美国人口 3.319 亿 (2021 年)
从 2020-01-01 到 2022-11-26
- 各种原因死亡人数: 9,691,052
- 新冠:1,073,957
1 | [ |
1 | let total = rs.reduce((pre,a)=>{ |
对比参考
- 中国人口:14.12 亿 (2021 年)
- 2021年 死亡 1014万人 死亡率为7.18‰