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
63
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
87
Web APIs 2019
orlando
0
130
Managing remote teams
orlando
0
70
How to be a Senior Software Engineer
orlando
0
150
Terraform Workshop
orlando
1
160
Infrastructure as Code with Terraform
orlando
0
290
Concurrencia, Paralelismo y el Event-loop
orlando
0
350
Talking Web Apps
orlando
0
100
Web Launchpad - Chelajs
orlando
0
220
Other Decks in Programming
See All in Programming
意外と簡単!?フロントエンドでパスキー認証を実現する WebAuthn
teamlab
PRO
2
720
AIでLINEスタンプを作ってみた
eycjur
1
230
Deep Dive into Kotlin Flow
jmatsu
1
310
Zendeskのチケットを Amazon Bedrockで 解析した
ryokosuge
3
290
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
8
3.5k
はじめてのMaterial3 Expressive
ym223
2
250
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
280
🔨 小さなビルドシステムを作る
momeemt
3
670
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
270
rage against annotate_predecessor
junk0612
0
160
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
110
ファインディ株式会社におけるMCP活用とサービス開発
starfish719
0
290
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
RailsConf 2023
tenderlove
30
1.2k
The Cult of Friendly URLs
andyhume
79
6.6k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Building an army of robots
kneath
306
46k
How GitHub (no longer) Works
holman
315
140k
The Pragmatic Product Professional
lauravandoore
36
6.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
GraphQLの誤解/rethinking-graphql
sonatard
72
11k
Agile that works and the tools we love
rasmusluckow
330
21k
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