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
48
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
97
Managing remote teams
orlando
0
55
How to be a Senior Software Engineer
orlando
0
120
Terraform Workshop
orlando
1
140
Infrastructure as Code with Terraform
orlando
0
260
Concurrencia, Paralelismo y el Event-loop
orlando
0
310
Talking Web Apps
orlando
0
67
Web Launchpad - Chelajs
orlando
0
180
Other Decks in Programming
See All in Programming
Using Livebook to build and deploy internal tools @ ElixirConf 2024
hugobarauna
0
250
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
220
いまから追い上げる、Jetpack Compose トレーニング
nyafunta9858
0
590
令和トラベルにおけるLLM活用事例:社内ツール開発から得た学びと実践
ippo012
0
210
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
120
LangGraphでのHuman-in-the-Loopの実装
os1ma
3
1.1k
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
490
API Platform for Laravel
dunglas
0
320
Scala におけるコンパイラエラーとの付き合い方
chencmd
2
430
エラーレスポンス設計から考える、0→1開発におけるGraphQLへの向き合い方
bicstone
5
1.5k
rbs-inlineを導入してYARDからRBSに移行する
euglena1215
1
290
Lessons by WebAssembly app in production on CDN Edge Computing Service
tetsuharuohzeki
0
210
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
354
29k
How GitHub (no longer) Works
holman
310
140k
How STYLIGHT went responsive
nonsquared
93
5.1k
Thoughts on Productivity
jonyablonski
66
4.2k
Intergalactic Javascript Robots from Outer Space
tanoku
268
26k
Designing Experiences People Love
moore
138
23k
Producing Creativity
orderedlist
PRO
340
39k
Rails Girls Zürich Keynote
gr2m
93
13k
Designing for humans not robots
tammielis
248
25k
Scaling GitHub
holman
458
140k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.8k
The Straight Up "How To Draw Better" Workshop
denniskardys
230
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