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
100
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
410
Talking Web Apps
orlando
0
140
Web Launchpad - Chelajs
orlando
0
260
Other Decks in Programming
See All in Programming
ALB ログから Trace を気合で繋げる技術
fohte
6
650
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
110
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.2k
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
230
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
220
FastAPI の並行処理モデルを完全に理解する
hoto17296
8
3k
Cloudflare is Agents
chimame
0
180
AIの中の人になってみる
htkym
0
120
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
440
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
400
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
160
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
730
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
440
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
260
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
220
Designing Experiences People Love
moore
143
24k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
250
The Language of Interfaces
destraynor
162
27k
Done Done
chrislema
186
16k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Crafting Experiences
bethany
1
260
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