Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
你懂了 JavaScript,也不懂 JavaScript - MOPCON 2021
Search
Huli
November 19, 2021
Programming
3
850
你懂了 JavaScript,也不懂 JavaScript - MOPCON 2021
Huli
November 19, 2021
Tweet
Share
More Decks by Huli
See All by Huli
ModernWeb 2018 - 輕鬆應付複雜的非同步操作:RxJS + Redux Observable
aszx87410
0
110
Attacking web without JS - CSS injection
aszx87410
0
2.8k
Front-end Security that Front-end developers don't know
aszx87410
2
5.4k
接觸資安才發現前端的水真深 - Modern Web 2021
aszx87410
0
1.7k
JSDC2020 - 用 API mocking 讓前端不再苦等待
aszx87410
0
1.2k
Other Decks in Programming
See All in Programming
自動テスト実行結果の目的を整理する / Organizing objectives of automated test results
twada
PRO
10
2.1k
オブジェクト指向は必要なのか / Is object-oriented needed?
kishida
27
19k
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
4
1.1k
クソコード動画『カプセル化 Mk-II』 で考える 上手くカプセル化できない理由 / encapsulation2
minodriven
11
8k
もうすぐ新年度、Babylon.jsがお勧めな3個の理由
hideg
0
170
object-oriented-conference-2024
fuwasegu
6
1.9k
App Router への移行は「改善」となり得るのか?/ Can migration to App Router be an improvement
takefumiyoshii
1
130
document.write再考
brn
5
2.5k
実践!RDRAを活用した既存システムの仕様変更 / Specification Changes in Existing Systems Utilizing RDRA
imamotohikaru
0
2.7k
Cloud RunとCloud PubSubでサーバレスなデータ基盤2024 with Terraform / Cloud Run and PubSub with Terraform
shinyorke
7
1.9k
PHP8の機能を使って堅牢にコードを書く
fendo181
6
2.6k
上手な探索的テストとその上達方法について
matsu802
4
660
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
58
4.9k
How to Ace a Technical Interview
jacobian
272
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
153
14k
Side Projects
sachag
451
41k
Embracing the Ebb and Flow
colly
78
4.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
Music & Morning Musume
bryan
39
5.5k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.8k
Gamification - CAS2011
davidbonilla
76
4.5k
GraphQLの誤解/rethinking-graphql
sonatard
48
9.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
185
15k
From Idea to $5000 a Month in 5 Months
shpigford
376
45k
Transcript
你懂了了 JavaScript,也不懂 JavaScript Huli @ MOPCON 2021
About 上半年年:OneDegree 前端⼯工程師
About 上半年年:OneDegree 前端⼯工程師 下半年年:Cymetrics 資安⼯工程師
開始之前,先來來個⼩小測驗
下列列各組「」內的字,讀⾳音相同的選項是 • (A) 令⼈人發「噱」/「遽」然⽽而逝 • (B) 同⼼心「戮」⼒力力/「蓼」菜成⾏行行 • (C) 寒「蛩」鳴秋/「煢」居荒野
• (D)「瓠」巴⿎鼓瑟/簞「瓢」屢屢空 出處:101 年年指考國⽂文
下列列各組「」內的字,讀⾳音相同的選項是 • (A) 令⼈人發「噱」/「遽」然⽽而逝 • (B) 同⼼心「戮」⼒力力/「蓼」菜成⾏行行 • (C) 寒「蛩」鳴秋/「煢」居荒野
• (D)「瓠」巴⿎鼓瑟/簞「瓢」屢屢空 出處:101 年年指考國⽂文
下列列各組「」內的字,讀⾳音相同的選項是 • (A) 令⼈人發「噱」/「遽」然⽽而逝 • (B) 同⼼心「戮」⼒力力/「蓼」菜成⾏行行 • (C) 寒「蛩」鳴秋/「煢」居荒野
• (D)「瓠」巴⿎鼓瑟/簞「瓢」屢屢空 出處:101 年年指考國⽂文
下列列各組「」內的字,讀⾳音相同的選項是 • (A) 令⼈人發「噱」/「遽」然⽽而逝 • (B) 同⼼心「戮」⼒力力/「蓼」菜成⾏行行 • (C) 寒「蛩」鳴秋/「煢」居荒野
• (D)「瓠」巴⿎鼓瑟/簞「瓢」屢屢空 出處:101 年年指考國⽂文
讓我們再來來⼀一個⼩小測驗
請問以下四個的結果是 [] + [] [] + {} {} + []
{} + {}
請問以下四個的結果是 [] + [] [] + {} {} + []
{} + {}
1. 這個對我寫 code 有幫助嗎? 2. 不知道的話,會容易易寫出 bug 嗎?
None
None
eslint: b is not defined
None
None
None
1. 比較不重要但有趣的知識 2. 重要的知識
1. 比較不重要但有趣的知識 2. 重要的知識 成為 JS ⼤大師 aka spec ⼤大師
1. 比較不重要但有趣的知識 2. 重要的知識 避免寫出 bug,寫出更更好的 code
時間有限的前提下,挑價值最⾼高的先學
Agenda 1.Type 2.Hoisting 3.This 4.Prototype 5.Async
Type
Number 跟 String
[1,5,3,11,7].sort()
[1,5,3,11,7].sort() [1,11,3,5,7]
None
None
None
None
3.3000000000000003
Number.EPSILON = 2^-52
Math.abs(0.1+0.2-0.3) < Number.EPSILON
None
None
None
None
Number.MAX_SAFE_INTEGER 9007199254740991
第七種資料型別 BigInt
重點 1. 排序時注意比較的是字典序 2. 注意數字加字串串會變字串串 3. 處理理⼩小數時注意浮點數問題 4. 處理理⼤大數時注意數字範圍 5.
⼤大數可以⽤用 BigInt
Hoisting
None
1 2 3 4
1 2 3 4
JS 在執⾏行行前就會做⼀一些處理理
None
重點 1. JS 還是有編譯的存在 2.在進入函式時就會對宣告做處理理
This
None
None
var q = document.query q() document.query()
var q = document.query q() document.query()
this 的值跟怎麼呼叫函式有關
var q = document.query q() document.query() this
var q = document.query q() document.query() this this?
None
None
None
None
None
None
TypeError Cannot read property 'setState' of undefined
this 的值跟怎麼呼叫函式有關
None
None
None
重點 1. 呼叫函式的⽅方式會影響 this 2. bind 可以綁定特定 this 3. call、apply
呼叫函式時可以指定 this 4. arrow function 也會改變 this
Prototype
None
(1).toString()
(1).toString() (1).__proto__ => Number.prototype
(1).toString() (1).__proto__ => Number.prototype Number.prototype.toString
(1).toString() (1).__proto__ => Number.prototype Number.prototype.toString
None
None
None
None
None
None
None
None
重點 1. prototype chain 的概念念 2. JS 透過 prototype chain
尋找 屬性跟⽅方法 3.透過全寫去呼叫函式
Async
None
None
None
callback !== 非同步
None
call stack task queue Web API main
call stack task queue Web API main setTimeout
call stack task queue Web API main 100ms, fn
call stack task queue Web API main fn
call stack task queue Web API main fn console
call stack task queue Web API main fn
call stack task queue Web API fn
call stack task queue Web API fn
call stack task queue Web API fn console
call stack task queue Web API fn
call stack task queue Web API
None
None
None
None
重點 1. callback !== 非同步 2. event loop 的運作⽅方式
Agenda 1.Type 2.Hoisting 3.This 4.Prototype 5.Async
1. 這個對我寫 code 有幫助 2. 不知道的話,會容易易寫出 bug