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
63
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
87
Web APIs 2019
orlando
0
130
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
350
Talking Web Apps
orlando
0
100
Web Launchpad - Chelajs
orlando
0
220
Other Decks in Programming
See All in Programming
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
110
機能追加とリーダー業務の類似性
rinchoku
2
1.3k
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
840
為你自己學 Python - 冷知識篇
eddie
1
350
AWS発のAIエディタKiroを使ってみた
iriikeita
1
180
私の後悔をAWS DMSで解決した話
hiramax
4
210
ProxyによるWindow間RPC機構の構築
syumai
3
1.2k
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
120
アルテニア コンサル/ITエンジニア向け 採用ピッチ資料
altenir
0
100
知っているようで知らない"rails new"の世界 / The World of "rails new" You Think You Know but Don't
luccafort
PRO
1
110
AIコーディングAgentとの向き合い方
eycjur
0
270
Laravel Boost 超入門
fire_arlo
3
210
Featured
See All Featured
Side Projects
sachag
455
43k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
A Tale of Four Properties
chriscoyier
160
23k
Code Review Best Practice
trishagee
70
19k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Agile that works and the tools we love
rasmusluckow
330
21k
Automating Front-end Workflow
addyosmani
1370
200k
KATA
mclloyd
32
14k
Writing Fast Ruby
sferik
628
62k
Six Lessons from altMBA
skipperchong
28
4k
Why Our Code Smells
bkeepers
PRO
339
57k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
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