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
同じってなんだ?
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Hirofumi Horiuchi
September 27, 2021
0
35
同じってなんだ?
Hirofumi Horiuchi
September 27, 2021
Tweet
Share
More Decks by Hirofumi Horiuchi
See All by Hirofumi Horiuchi
Stimulusのはなし
h_reader
0
36
OSSを読んでみた?
h_reader
0
54
vue_js_composition_api
h_reader
0
67
秒速でリリースするWebアプリ.pdf
h_reader
0
45
はじめよう async/await
h_reader
0
49
Node.jsではじめるオレオレツールの世界
h_reader
0
490
Featured
See All Featured
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
The Language of Interfaces
destraynor
162
26k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
HDC tutorial
michielstock
1
370
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
Faster Mobile Websites
deanohume
310
31k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
GitHub's CSS Performance
jonrohan
1032
470k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
110
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
Transcript
同じってなんだ?
Hello! I am Hirofumi Horiuchi. Corp: Job: IoT Engineer Hobby:
Camp, Watting Football @h_reader 2
“ プログラミングの世界で 同じかどうかを比較するには 主に == を使います。
“ a == 2 とか
“ Javascriptでは == と === があり これは違う比較です
“ Javascriptでいう 同じとは何なのでしょうか?
== と === の違い == とは 等値演算子 (ざっくり等しい) === とは同値演算子
(きっちり等しい)
“ 10 と 10 は等しい?
“ 10 == 10 -> true 10 === 10 ->
true
“ 10 と “10“ は等しい?
“ 10 == “10” -> true 10 === “10” ->
false
“ 16 と “0x10” は等しい?
“ 16 == “0x10” -> true 16 === “0x10” ->
false
“ 1 と true は等しい?
“ 1 == true -> true 1 === true ->
false
“ 1 と “true” は等しい?
“ 1 == ‘true’ -> false 1 === ‘true’ ->
false
“ “str”と new String(‘str’)は等しい?
“ “str” == new String(“str”) -> true “str” === new
String(“str”) -> false
“ null と undifined は等しい?
“ null == undefined -> true null === undefined ->
false
“ null と “” は等しい?
“ null == “” -> false null === “” ->
false
== と === の違いまとめ 条件式 == === 10 == 10
true true 10 == “10” true false 16 == “0x10” true false 1 == true true false 1 == ‘true’ false false “str” == new String(“str”) true false null == undefined true false “” == null false false
結局どう使えばいいの? ・値を比較したい場合、 === を使った方が安全 (10 と “10” は別だから) ・Nullチェックは、 ==
を使うのが楽 (null も undefined も、両方チェックしたいから) ただし、空文字は引っかからないので注意 ・Switch文は === の比較になる ・やはりエディタはVSCode
26 Thanks! Any questions? You can find me at ▪
@h_reader