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
66
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
93
Web APIs 2019
orlando
0
150
Managing remote teams
orlando
0
72
How to be a Senior Software Engineer
orlando
0
150
Terraform Workshop
orlando
1
170
Infrastructure as Code with Terraform
orlando
0
300
Concurrencia, Paralelismo y el Event-loop
orlando
0
370
Talking Web Apps
orlando
0
110
Web Launchpad - Chelajs
orlando
0
230
Other Decks in Programming
See All in Programming
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
410
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
840
マスタデータ問題、マイクロサービスでどう解くか
kts
0
140
Tinkerbellから学ぶ、Podで DHCPをリッスンする手法
tomokon
0
140
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
410
Patterns of Patterns
denyspoltorak
0
370
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
420
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
5
1.3k
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
3.1k
Grafana:建立系統全知視角的捷徑
blueswen
0
240
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.8k
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
480
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.4k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
2
3.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
Heart Work Chapter 1 - Part 1
lfama
PRO
3
35k
How to make the Groovebox
asonas
2
1.8k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
38
RailsConf 2023
tenderlove
30
1.3k
Deep Space Network (abreviated)
tonyrice
0
22
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
210
Accessibility Awareness
sabderemane
0
24
The Art of Programming - Codeland 2020
erikaheidi
56
14k
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