Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
90
Web APIs 2019
orlando
0
140
Managing remote teams
orlando
0
71
How to be a Senior Software Engineer
orlando
0
150
Terraform Workshop
orlando
1
160
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コーディングエージェント(Gemini)
kondai24
0
200
FluorTracer / RayTracingCamp11
kugimasa
0
220
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
420
認証・認可の基本を学ぼう後編
kouyuume
0
180
AWS CDKの推しポイントN選
akihisaikeda
1
240
AIコーディングエージェント(skywork)
kondai24
0
150
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
3
790
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
110
connect-python: convenient protobuf RPC for Python
anuraaga
0
380
まだ間に合う!Claude Code元年をふりかえる
nogu66
2
240
スタートアップを支える技術戦略と組織づくり
pospome
8
16k
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
160
Featured
See All Featured
Practical Orchestrator
shlominoach
190
11k
We Have a Design System, Now What?
morganepeng
54
7.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Embracing the Ebb and Flow
colly
88
4.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
700
Raft: Consensus for Rubyists
vanstee
141
7.2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
The Language of Interfaces
destraynor
162
25k
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