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
62
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
81
Web APIs 2019
orlando
0
130
Managing remote teams
orlando
0
67
How to be a Senior Software Engineer
orlando
0
140
Terraform Workshop
orlando
1
160
Infrastructure as Code with Terraform
orlando
0
280
Concurrencia, Paralelismo y el Event-loop
orlando
0
350
Talking Web Apps
orlando
0
96
Web Launchpad - Chelajs
orlando
0
210
Other Decks in Programming
See All in Programming
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
270
Team operations that are not burdened by SRE
kazatohiei
1
310
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
Hypervel - A Coroutine Framework for Laravel Artisans
albertcht
1
130
Discover Metal 4
rei315
2
140
RailsGirls IZUMO スポンサーLT
16bitidol
0
190
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
120
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
760
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
5
1.1k
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
780
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
150
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
130
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
970
BBQ
matthewcrist
89
9.7k
Making Projects Easy
brettharned
116
6.3k
Thoughts on Productivity
jonyablonski
69
4.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
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