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
86
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
88
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
140
Web Launchpad - Chelajs
orlando
0
260
Other Decks in Programming
See All in Programming
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
140
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
150
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
350
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
660
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
710
AIで効率化できた業務・日常
ochtum
0
140
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
360
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.4k
Vite+ Unified Toolchain for the Web
naokihaba
0
320
Inside Stream API
skrb
1
740
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
We Are The Robots
honzajavorek
0
250
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
420
Mobile First: as difficult as doing things right
swwweet
225
10k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
YesSQL, Process and Tooling at Scale
rocio
174
15k
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