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
65
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
88
Web APIs 2019
orlando
0
140
Managing remote teams
orlando
0
70
How to be a Senior Software Engineer
orlando
0
150
Terraform Workshop
orlando
1
160
Infrastructure as Code with Terraform
orlando
0
290
Concurrencia, Paralelismo y el Event-loop
orlando
0
360
Talking Web Apps
orlando
0
100
Web Launchpad - Chelajs
orlando
0
220
Other Decks in Programming
See All in Programming
LLMとPlaywright/reg-suitを活用した jQueryリファクタリングの実際
kinocoboy2
4
660
ABEMAモバイルアプリが Kotlin Multiplatformと歩んだ5年 ─ 導入と運用、成功と課題 / iOSDC 2025
akkyie
0
310
あなたの知らない「動画広告」の世界 - iOSDC Japan 2025
ukitaka
0
350
CSC305 Lecture 02
javiergs
PRO
1
260
非同期jobをtransaction内で 呼ぶなよ!絶対に呼ぶなよ!
alstrocrack
0
490
WebエンジニアがSwiftをブラウザで動かすプレイグラウンドを作ってみた
ohmori_yusuke
0
170
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
2
120
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
130
ИИ-Агенты в каждый дом – Алексей Порядин, PythoNN
sobolevn
0
150
フロントエンド開発に役立つクライアントプログラム共通のノウハウ / Universal client-side programming best practices for frontend development
nrslib
7
3.9k
AIエージェント時代における TypeScriptスキーマ駆動開発の新たな役割
bicstone
4
1.5k
CSC305 Lecture 04
javiergs
PRO
0
230
Featured
See All Featured
Scaling GitHub
holman
463
140k
4 Signs Your Business is Dying
shpigford
185
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
It's Worth the Effort
3n
187
28k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
188
55k
Statistics for Hackers
jakevdp
799
220k
We Have a Design System, Now What?
morganepeng
53
7.8k
Fireside Chat
paigeccino
40
3.7k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
610
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
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