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
52
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
67
Web APIs 2019
orlando
0
110
Managing remote teams
orlando
0
58
How to be a Senior Software Engineer
orlando
0
120
Terraform Workshop
orlando
1
140
Infrastructure as Code with Terraform
orlando
0
270
Concurrencia, Paralelismo y el Event-loop
orlando
0
320
Talking Web Apps
orlando
0
77
Web Launchpad - Chelajs
orlando
0
190
Other Decks in Programming
See All in Programming
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
290
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
180
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.3k
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
170
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
7
1.4k
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.9k
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
420
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.4k
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.9k
HTML/CSS超絶浅い説明
yuki0329
0
190
Azure AI Foundryのご紹介
qt_luigi
1
210
rails newと同時に型を書く
aki19035vc
5
710
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
3k
For a Future-Friendly Web
brad_frost
176
9.5k
Code Reviewing Like a Champion
maltzj
521
39k
Mobile First: as difficult as doing things right
swwweet
222
9k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
3
180
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
173
51k
Into the Great Unknown - MozCon
thekraken
34
1.6k
Building Applications with DynamoDB
mza
93
6.2k
Agile that works and the tools we love
rasmusluckow
328
21k
Designing for Performance
lara
604
68k
4 Signs Your Business is Dying
shpigford
182
22k
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