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 Type Conversions
Search
Orlando Del Aguila
March 13, 2015
Programming
75
1
Share
JavaScript Type Conversions
JavaScript Type Conversions and some explanations to the Gary Bernhardt's wat lighting talk
Orlando Del Aguila
March 13, 2015
More Decks by Orlando Del Aguila
See All by Orlando Del Aguila
Open Source + Nonprofits = 💪
orlando
0
110
Web APIs 2019
orlando
0
160
Managing remote teams
orlando
0
80
How to be a Senior Software Engineer
orlando
0
160
Terraform Workshop
orlando
1
180
Infrastructure as Code with Terraform
orlando
0
320
Concurrencia, Paralelismo y el Event-loop
orlando
0
390
Talking Web Apps
orlando
0
130
Web Launchpad - Chelajs
orlando
0
250
Other Decks in Programming
See All in Programming
KagglerがMixSeekを触ってみた
morim
0
390
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.5k
AIエージェントで業務改善してみた
taku271
0
520
[RubyKaigi 2026] Require Hooks
palkan
1
190
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
360
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
6.5k
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
120
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
140
アーキテクチャモダナイゼーションとは何か
nwiizo
17
5.1k
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
210
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
780
AI-DLC Deep Dive
yuukiyo
8
4k
Featured
See All Featured
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
170
Faster Mobile Websites
deanohume
310
31k
Why Our Code Smells
bkeepers
PRO
340
58k
HDC tutorial
michielstock
2
630
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Statistics for Hackers
jakevdp
799
230k
Rails Girls Zürich Keynote
gr2m
96
14k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Google's AI Overviews - The New Search
badams
0
970
Mobile First: as difficult as doing things right
swwweet
225
10k
Transcript
JavaScript Type Conversions
JavaScript Primitives yes, js has primitives
1. undefined 2. null 3. number 4. string 5. boolean
1. undefined 2. null yep, is not an object 3.
number 4. string 5. boolean
JavaScript Binary Operators we are going to address only -
and +
On doubt check the spec
http://www.ecma-international.org/ecma-262/5.1/#sec-11.6.1 http://www.ecma-international.org/ecma-262/5.1/#sec-11.6.2
+ Operator
If lprim or rprim are strings, then concatenate lprim and
rprim and return the result
- Operator
ToNumber(lprim) - ToNumber(rprim)
Examples
var a, b; a = "bla"; b = "ble"; a
+ b; //=> "blable" a - b; //=> "NaN" a = "5"; b = "4"; a + b; //=> "54" a - b; //=> 1
var obj = { valueOf: function valueOf() { console.log("valueOf"); return
{}; // not a primitive }, toString: function toString() { console.log("toString"); return {}; // not a primitive } }; obj - 1; // valueOf // toString // error obj + 1; // valueOf // toString // error
var func = function () { console.log('exec'); return { valueOf:
function valueOf() { console.log("valueOf"); return {}; // not a primitive }, toString: function toString() { console.log("toString"); return {}; // not a primitive } }; }; func() + 1; // exec // valueOf // toString // error
{} + [] //=> +[] == 0 [] + {}
//=> '' + '[object Object]' == '[object Object]' [] - {} //=> 0 - NaN == NaN {} - [] //=> -[] == -0
None
WAT https://www.destroyallsoftware.com/talks/wat