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
1
59
JavaScript Type Conversions
JavaScript Type Conversions and some explanations to the Gary Bernhardt's wat lighting talk
Orlando Del Aguila
March 13, 2015
Tweet
Share
More Decks by Orlando Del Aguila
See All by Orlando Del Aguila
Open Source + Nonprofits = 💪
orlando
0
74
Web APIs 2019
orlando
0
120
Managing remote teams
orlando
0
60
How to be a Senior Software Engineer
orlando
0
140
Terraform Workshop
orlando
1
150
Infrastructure as Code with Terraform
orlando
0
280
Concurrencia, Paralelismo y el Event-loop
orlando
0
340
Talking Web Apps
orlando
0
89
Web Launchpad - Chelajs
orlando
0
200
Other Decks in Programming
See All in Programming
TVer iOSチームの共通認識の作り方 - Findy Job LT iOSアプリ開発の裏側 開発組織が向き合う課題とこれから
techtver
PRO
0
710
技術的負債と戦略的に戦わざるを得ない場合のオブザーバビリティ活用術 / Leveraging Observability When Strategically Dealing with Technical Debt
yoshiyoshifujii
0
160
がんばりすぎないコーディングルール運用術
tsukakei
1
180
JSAI2025 RecSysChallenge2024 優勝報告
unonao
1
380
Interface vs Types ~型推論が過多推論~
hirokiomote
1
230
DevDay2025-OracleDatabase-kernel-addressing-history
oracle4engineer
PRO
7
1.6k
Practical Domain-Driven Design - Workshop at NDC 2025
mufrid
0
130
What Spring Developers Should Know About Jakarta EE
ivargrimstad
1
610
Blueskyのプラグインを作ってみた
hakkadaikon
1
290
Doma で目指す ORM 最適解
nakamura_to
1
160
ts-morph実践:型を利用するcodemodのテクニック
ypresto
1
540
💎 My RubyKaigi Effect in 2025: Top Ruby Companies 🌐
yasulab
PRO
1
130
Featured
See All Featured
Become a Pro
speakerdeck
PRO
28
5.4k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
For a Future-Friendly Web
brad_frost
178
9.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
6
660
Balancing Empowerment & Direction
lara
1
84
Embracing the Ebb and Flow
colly
85
4.7k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
How to train your dragon (web standard)
notwaldorf
92
6k
The Cost Of JavaScript in 2023
addyosmani
49
8.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
180
53k
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