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
What We Talk About When We Talk About XP
m_seki
2
340
ソフトウェアラスタライザ
fadis
1
780
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
160
ALB ログから Trace を気合で繋げる技術
fohte
7
860
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.3k
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.7k
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
820
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
280
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
500
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
350
初めての模倣学習とVLA
natsutan
0
460
Deep dive into the select statement (GopherCon UK)
jespino
0
170
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
300
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
400
Facilitating Awesome Meetings
lara
57
7.1k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
320
From π to Pie charts
rasagy
0
350
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
920
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Prompt Engineering for Job Search
mfonobong
0
440
Into the Great Unknown - MozCon
thekraken
41
2.7k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
260
Unsuck your backbone
ammeep
672
58k
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