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
53
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
67
Web APIs 2019
orlando
0
110
Managing remote teams
orlando
0
58
How to be a Senior Software Engineer
orlando
0
120
Terraform Workshop
orlando
1
150
Infrastructure as Code with Terraform
orlando
0
270
Concurrencia, Paralelismo y el Event-loop
orlando
0
330
Talking Web Apps
orlando
0
83
Web Launchpad - Chelajs
orlando
0
200
Other Decks in Programming
See All in Programming
eBPF Updates (March 2025)
kentatada
0
130
snacks.nvim内のセットアップ不要なプラグインを紹介 / introduce_snacks_nvim
uhooi
0
320
今から始めるCursor / Windsurf / Cline
kengo_hayano
0
110
RailsでCQRS/ESをやってみたきづき
suzukimar
2
1.5k
英語文法から学ぶ、クリーンな設計の秘訣
newnomad
1
270
Modern Angular:Renovation for Your Applications @angularDays 2025 Munich
manfredsteyer
PRO
0
110
goにおける コネクションプールの仕組み を軽く掘って見た
aronokuyama
0
110
PHPUnit 高速化テクニック / PHPUnit Speedup Techniques
pinkumohikan
1
1.1k
コンテナでLambdaをデプロイするときに知っておきたかったこと
_takahash
0
140
PHPでお金を扱う時、終わりのない 謎の1円調査の旅にでなくて済む方法
nakka
3
970
データベースエンジニアの仕事を楽にする。PgAssistantの紹介
nnaka2992
9
4.1k
プログラミング教育のコスパの話
superkinoko
0
110
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Side Projects
sachag
452
42k
What's in a price? How to price your products and services
michaelherold
244
12k
Six Lessons from altMBA
skipperchong
27
3.7k
Typedesign – Prime Four
hannesfritz
41
2.6k
Making Projects Easy
brettharned
116
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Building Your Own Lightsaber
phodgson
104
6.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
How STYLIGHT went responsive
nonsquared
99
5.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