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
55
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
70
Web APIs 2019
orlando
0
120
Managing remote teams
orlando
0
59
How to be a Senior Software Engineer
orlando
0
130
Terraform Workshop
orlando
1
150
Infrastructure as Code with Terraform
orlando
0
270
Concurrencia, Paralelismo y el Event-loop
orlando
0
340
Talking Web Apps
orlando
0
87
Web Launchpad - Chelajs
orlando
0
200
Other Decks in Programming
See All in Programming
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
190
Browser and UI #2 HTML/ARIA
ken7253
2
150
State of Namespace
tagomoris
5
2.2k
MCP調べてみました! / Exploring MCP
uhzz
2
2.3k
Youtube Lofier - Chrome拡張開発
ninikoko
0
2.5k
KANNA Android の技術的課題と取り組み
watabee
0
140
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
4
1.3k
파급효과: From AI to Android Development
l2hyunwoo
0
140
状態と共に暮らす:ステートフルへの挑戦
ypresto
3
980
Road to RubyKaigi: Making Tinny Chiptunes with Ruby
makicamel
4
490
Qiita Bash
mercury_dev0517
2
210
VitestのIn-Source Testingが便利
taro28
8
2.3k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
69
4.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Writing Fast Ruby
sferik
628
61k
Code Reviewing Like a Champion
maltzj
523
40k
Designing Experiences People Love
moore
142
24k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
The Pragmatic Product Professional
lauravandoore
33
6.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.6k
Why Our Code Smells
bkeepers
PRO
336
57k
Fontdeck: Realign not Redesign
paulrobertlloyd
84
5.5k
How to Ace a Technical Interview
jacobian
276
23k
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