Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
同じってなんだ?
Search
Hirofumi Horiuchi
September 27, 2021
41
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
同じってなんだ?
Hirofumi Horiuchi
September 27, 2021
More Decks by Hirofumi Horiuchi
See All by Hirofumi Horiuchi
Stimulusのはなし
h_reader
0
43
OSSを読んでみた?
h_reader
0
59
vue_js_composition_api
h_reader
0
72
秒速でリリースするWebアプリ.pdf
h_reader
0
53
はじめよう async/await
h_reader
0
57
Node.jsではじめるオレオレツールの世界
h_reader
0
520
Featured
See All Featured
Abbi's Birthday
coloredviolet
4
10k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
460
Bash Introduction
62gerente
615
220k
Technical Leadership for Architectural Decision Making
baasie
3
600
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Paper Plane (Part 1)
katiecoart
PRO
2
12k
The Cost Of JavaScript in 2023
addyosmani
55
10k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
The SEO identity crisis: Don't let AI make you average
varn
0
590
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
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