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
71
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
110
Web APIs 2019
orlando
0
150
Managing remote teams
orlando
0
78
How to be a Senior Software Engineer
orlando
0
160
Terraform Workshop
orlando
1
180
Infrastructure as Code with Terraform
orlando
0
320
Concurrencia, Paralelismo y el Event-loop
orlando
0
390
Talking Web Apps
orlando
0
130
Web Launchpad - Chelajs
orlando
0
250
Other Decks in Programming
See All in Programming
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
430
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
370
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
140
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
280
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
170
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
160
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
120
ファインチューニングせずメインコンペを解く方法
pokutuna
0
210
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
440
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
470
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
240
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.1k
Featured
See All Featured
Color Theory Basics | Prateek | Gurzu
gurzu
0
270
Building Applications with DynamoDB
mza
96
7k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
200
Claude Code のすすめ
schroneko
67
220k
Docker and Python
trallard
47
3.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
How STYLIGHT went responsive
nonsquared
100
6k
GraphQLとの向き合い方2022年版
quramy
50
14k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Scaling GitHub
holman
464
140k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
200
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