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
1
70
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
100
Web APIs 2019
orlando
0
150
Managing remote teams
orlando
0
75
How to be a Senior Software Engineer
orlando
0
150
Terraform Workshop
orlando
1
170
Infrastructure as Code with Terraform
orlando
0
310
Concurrencia, Paralelismo y el Event-loop
orlando
0
380
Talking Web Apps
orlando
0
120
Web Launchpad - Chelajs
orlando
0
250
Other Decks in Programming
See All in Programming
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.8k
RubyとGoでゼロから作る証券システム: 高信頼性が求められるシステムのコードの外側にある設計と運用のリアル
free_world21
0
230
朝日新聞のデジタル版を支えるGoバックエンド ー価値ある情報をいち早く確実にお届けするために
junkiishida
1
480
Python’s True Superpower
hynek
0
200
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
340
浮動小数の比較について
kishikawakatsumi
0
390
CSC307 Lecture 13
javiergs
PRO
0
310
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
160
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
710
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
3
1.1k
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
210
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
130
Featured
See All Featured
Building an army of robots
kneath
306
46k
We Are The Robots
honzajavorek
0
190
Raft: Consensus for Rubyists
vanstee
141
7.3k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
220
Designing Experiences People Love
moore
143
24k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.4k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
470
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
960
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Optimizing for Happiness
mojombo
378
71k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
850
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