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
82
1
Share
JavaScript Type Conversions
JavaScript Type Conversions and some explanations to the Gary Bernhardt's wat lighting talk
Orlando Del Aguila
March 13, 2015
More Decks by Orlando Del Aguila
See All by Orlando Del Aguila
Open Source + Nonprofits = 💪
orlando
0
110
Web APIs 2019
orlando
0
170
Managing remote teams
orlando
0
86
How to be a Senior Software Engineer
orlando
0
160
Terraform Workshop
orlando
1
180
Infrastructure as Code with Terraform
orlando
0
330
Concurrencia, Paralelismo y el Event-loop
orlando
0
400
Talking Web Apps
orlando
0
130
Web Launchpad - Chelajs
orlando
0
260
Other Decks in Programming
See All in Programming
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
0
200
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
2.2k
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
1.3k
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
250
AI時代のUIはどこへ行く?その2!
yusukebe
15
4.4k
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
320
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
230
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
300
Hive Metastoreを通して学ぶIceberg REST Catalog ― 仕様から実装まで
okumin
0
310
Talking to terminals (and how they talk back) (KotlinConf 2026)
jakewharton
PRO
1
160
OSもどきOS
arkw
0
350
AIとRubyの静的型付け
ukin0k0
0
470
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
1
340
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
KATA
mclloyd
PRO
35
15k
Typedesign – Prime Four
hannesfritz
42
3.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
sira's awesome portfolio website redesign presentation
elsirapls
0
270
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
190
The Curse of the Amulet
leimatthew05
1
13k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
240
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
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