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
52
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
140
Infrastructure as Code with Terraform
orlando
0
270
Concurrencia, Paralelismo y el Event-loop
orlando
0
330
Talking Web Apps
orlando
0
79
Web Launchpad - Chelajs
orlando
0
190
Other Decks in Programming
See All in Programming
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
3
3.2k
定理証明プラットフォーム lapisla.net
abap34
1
670
ASP.NET Core の OpenAPIサポート
h455h1
0
160
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
240
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
240
WebDriver BiDiとは何なのか
yotahada3
1
100
ErdMap: Thinking about a map for Rails applications
makicamel
1
1.1k
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
3
1.1k
為你自己學 Python
eddie
0
540
最近のVS Codeで気になるニュース 2025/01
74th
1
240
Запуск 1С:УХ в крупном энтерпрайзе: мечта и реальность ПМа
lamodatech
0
990
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
140
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Thoughts on Productivity
jonyablonski
68
4.4k
Designing for Performance
lara
604
68k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
39
1.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
GraphQLとの向き合い方2022年版
quramy
44
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
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