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
1k
你懂了 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
170
Attacking web without JS - CSS injection
aszx87410
0
3.1k
Front-end Security that Front-end developers don't know
aszx87410
2
5.7k
接觸資安才發現前端的水真深 - Modern Web 2021
aszx87410
0
2.3k
JSDC2020 - 用 API mocking 讓前端不再苦等待
aszx87410
0
1.3k
Other Decks in Programming
See All in Programming
PEPCは何を変えようとしていたのか
ken7253
3
290
React 19アップデートのために必要なこと
uhyo
8
1.5k
バッチを作らなきゃとなったときに考えること
irof
2
540
Honoとフロントエンドの 型安全性について
yodaka
7
1.5k
Amazon Bedrockマルチエージェントコラボレーションを諦めてLangGraphに入門してみた
akihisaikeda
1
140
もう少しテストを書きたいんじゃ〜 #phpstudy
o0h
PRO
19
4.1k
『テスト書いた方が開発が早いじゃん』を解き明かす #phpcon_nagoya
o0h
PRO
9
2.5k
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
7
4.2k
コードを読んで理解するko build
bells17
1
110
パスキーのすべて ── 導入・UX設計・実装の紹介 / 20250213 パスキー開発者の集い
kuralab
3
910
Visual StudioのGitHub Copilotでいろいろやってみる
tomokusaba
1
210
CDK開発におけるコーディング規約の運用
yamanashi_ren01
2
260
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
RailsConf 2023
tenderlove
29
1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
430
Automating Front-end Workflow
addyosmani
1369
200k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.4k
Embracing the Ebb and Flow
colly
84
4.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
11
1.3k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
650
Thoughts on Productivity
jonyablonski
69
4.5k
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