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
97
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
120
Web APIs 2019
orlando
0
170
Managing remote teams
orlando
0
88
How to be a Senior Software Engineer
orlando
0
170
Terraform Workshop
orlando
1
190
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
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
520
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
400
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
110
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.5k
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
140
VibeCodingからAgenticWorkflowへ
starfish719
0
220
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.8k
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
820
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
170
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.4k
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
340
Android CLI
fornewid
0
210
Featured
See All Featured
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
Designing for Performance
lara
611
70k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
460
Practical Orchestrator
shlominoach
191
12k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Leo the Paperboy
mayatellez
8
2.1k
KATA
mclloyd
PRO
35
15k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
280
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
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