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
46
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
63
Web APIs 2019
orlando
0
93
Managing remote teams
orlando
0
55
How to be a Senior Software Engineer
orlando
0
110
Terraform Workshop
orlando
1
130
Infrastructure as Code with Terraform
orlando
0
260
Concurrencia, Paralelismo y el Event-loop
orlando
0
300
Talking Web Apps
orlando
0
63
Web Launchpad - Chelajs
orlando
0
170
Other Decks in Programming
See All in Programming
Android開発者のための Kotlin Multiplatform入門
ntaro
0
190
最近追加した型の紹介とその振り返り
aki19035vc
0
170
CSC307 Lecture 07
javiergs
PRO
0
220
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
Rubyのパフォーマンスプロファイリングの改善 / Enhancing performance profiling for Ruby
osyoyu
1
410
SRE チーム立ち上げ前に考えたこと・取り組んだこと / Considerations and Preparations Before Establishing an SRE Team
mackey0225
3
320
Rustのweb開発を助ける 便利なツール紹介
yuki0418
1
190
12年前の『型システム入門』翻訳の思い出話
mame
11
1.2k
The rollercoaster of releasing an Android, iOS, and macOS app with Kotlin Multiplatform | droidcon Berlin
prof18
0
110
スクラムマスターって孤独じゃないですか?
yoshitaroyoyo
1
140
ぼっちを避けて楽しむためのアノテコノテ / Various Tips and Tricks to Avoid Loneliness and Have Fun
nrslib
3
1.7k
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
370
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Building a Scalable Design System with Sketch
lauravandoore
458
32k
Building Applications with DynamoDB
mza
89
5.8k
Happy Clients
brianwarren
94
6.5k
Documentation Writing (for coders)
carmenintech
63
4.2k
GraphQLの誤解/rethinking-graphql
sonatard
59
9.6k
Typedesign – Prime Four
hannesfritz
37
2.2k
What's in a price? How to price your products and services
michaelherold
239
11k
Music & Morning Musume
bryan
43
5.9k
How STYLIGHT went responsive
nonsquared
93
5k
Pencils Down: Stop Designing & Start Developing
hursman
118
11k
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