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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Orlando Del Aguila
March 13, 2015
Programming
77
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
83
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
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.7k
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
実用!Hono RPC2026
yodaka
2
310
継続的な負荷検証を目指して
pyama86
3
1k
My daily life on Ruby
a_matsuda
3
200
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
Agentic Elixir
whatyouhide
0
440
空間オーディオの活用
objectiveaudio
0
140
Programming with a DJ Controller — not vibe coding
m_seki
3
810
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
560
Explore CoroutineScope
tomoeng11
0
180
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
280
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Navigating Weather and Climate Data
rabernat
0
190
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
How to build a perfect <img>
jonoalderson
1
5.5k
Designing Experiences People Love
moore
143
24k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
110
Accessibility Awareness
sabderemane
1
110
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
790
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
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