Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
JavaScript Type Conversions
Orlando Del Aguila
March 13, 2015
Programming
1
35
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
39
Web APIs 2019
orlando
0
57
Managing remote teams
orlando
0
36
How to be a Senior Software Engineer
orlando
0
71
Terraform Workshop
orlando
1
97
Infrastructure as Code with Terraform
orlando
0
210
Concurrencia, Paralelismo y el Event-loop
orlando
0
220
Talking Web Apps
orlando
0
31
Web Launchpad - Chelajs
orlando
0
130
Other Decks in Programming
See All in Programming
Micro Frontends with Module Federation: Beyond the Basics @jax2022
manfredsteyer
PRO
1
290
roadmap to rust 2024
matsu7874
1
860
heyにおけるSREの大切さ~マルチプロダクト運用の「楽しさ」と「難しさ」および今後の展望~
fufuhu
3
1.8k
Yumemi.apk #6 ~ゆめみのAndroidエンジニア 日頃の成果大発表会!~ Session 2
blendthink
1
210
Loom is Blooming
josepaumard
3
550
Cloud-Conference-Day-Spring Cloud + Spring Webflux: como desenvolver seu primeiro microsserviço reativo em Java?
kamilahsantos
1
120
未経験QAの私が、よきQA(Question Asker) になっていく物語
atamaplus
0
290
About Type Syntax Proposal
quramy
1
1.2k
ebpfとWASMに思いを馳せる2022 / techfeed-conference-2022-ebpf-wasm-amsy810
masayaaoyama
0
710
アプリのログをチーム外で活用してもらうためにやったこと
shotakashihara
0
190
Reactでアプリケーションを構築する多様化
sakito
4
3.4k
Becoming an Android Librarian
skydoves
3
470
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
4
2k
The World Runs on Bad Software
bkeepers
PRO
56
5.2k
WebSockets: Embracing the real-time Web
robhawkes
57
5k
What the flash - Photography Introduction
edds
61
10k
Why Our Code Smells
bkeepers
PRO
324
54k
Documentation Writing (for coders)
carmenhchung
48
2.5k
The Power of CSS Pseudo Elements
geoffreycrofte
46
3.9k
The Language of Interfaces
destraynor
148
20k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
7
1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
350
21k
KATA
mclloyd
7
8.6k
Building a Scalable Design System with Sketch
lauravandoore
447
30k
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