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
Drawing Heighway’s Dragon- Recursive Function Rewrite- From Imperative Style in Pascal 64 To Functional Style in Scala 3
philipschwarz
PRO
0
150
Visual StudioのGitHub Copilotでいろいろやってみる
tomokusaba
1
220
Boos Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
600
クックパッド検索システム統合/Cookpad Search System Consolidation
giga811
0
140
GoとPHPのインターフェイスの違い
shimabox
2
220
.NET Frameworkでも汎用ホストが使いたい!
tomokusaba
0
210
React 19アップデートのために必要なこと
uhyo
8
1.6k
Duke on CRaC with Jakarta EE
ivargrimstad
0
110
kintone開発を効率化するためにチームで試した施策とその結果を大放出!
oguemon
0
330
良いコードレビューとは
danimal141
9
7.4k
[JAWS DAYS 2025] 最近の DB の競合解決の仕組みが分かった気になってみた
maroon1st
0
160
ソフトウェアエンジニアの成長
masuda220
PRO
12
2.2k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
115
51k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.2k
Become a Pro
speakerdeck
PRO
26
5.2k
Done Done
chrislema
182
16k
Facilitating Awesome Meetings
lara
53
6.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
Designing for humans not robots
tammielis
250
25k
The World Runs on Bad Software
bkeepers
PRO
67
11k
A Tale of Four Properties
chriscoyier
158
23k
Documentation Writing (for coders)
carmenintech
68
4.6k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Unsuck your backbone
ammeep
669
57k
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