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
66
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
90
Web APIs 2019
orlando
0
140
Managing remote teams
orlando
0
71
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
360
Talking Web Apps
orlando
0
110
Web Launchpad - Chelajs
orlando
0
220
Other Decks in Programming
See All in Programming
AIを駆使して新しい技術を効率的に理解する方法
nogu66
1
660
Level up your Gemini CLI - D&D Style!
palladius
1
110
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
2
8.1k
connect-python: convenient protobuf RPC for Python
anuraaga
0
200
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
110
[堅牢.py #1] テストを書かない研究者に送る、最初にテストを書く実験コード入門 / Let's start your ML project by writing tests
shunk031
11
5.6k
r2-image-worker
yusukebe
1
180
Promise.tryで実現する新しいエラーハンドリング New error handling with Promise try
bicstone
3
1.4k
Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Data Structures: Linked Lists and Queues for Reactivity
konkarin
1
340
Eloquentを使ってどこまでコードの治安を保てるのか?を新人が考察してみた
itokoh0405
0
3.2k
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
470
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.2k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1k
4 Signs Your Business is Dying
shpigford
186
22k
Typedesign – Prime Four
hannesfritz
42
2.9k
Facilitating Awesome Meetings
lara
57
6.6k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Practical Orchestrator
shlominoach
190
11k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8k
Site-Speed That Sticks
csswizardry
13
970
Designing for humans not robots
tammielis
254
26k
Music & Morning Musume
bryan
46
7k
Speed Design
sergeychernyshev
33
1.2k
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