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
67
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
98
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
310
Concurrencia, Paralelismo y el Event-loop
orlando
0
380
Talking Web Apps
orlando
0
120
Web Launchpad - Chelajs
orlando
0
240
Other Decks in Programming
See All in Programming
Fluid Templating in TYPO3 14
s2b
0
130
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
490
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
620
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
150
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
190
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
540
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
170
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
Vibe codingでおすすめの言語と開発手法
uyuki234
0
220
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
170
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Making Projects Easy
brettharned
120
6.6k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
580
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.6k
HDC tutorial
michielstock
1
360
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
140
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Raft: Consensus for Rubyists
vanstee
141
7.3k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
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