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
56
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
73
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
280
Concurrencia, Paralelismo y el Event-loop
orlando
0
340
Talking Web Apps
orlando
0
88
Web Launchpad - Chelajs
orlando
0
200
Other Decks in Programming
See All in Programming
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
philipschwarz
PRO
0
170
プロダクトエンジニアのしごと 〜 受託 × 高難度を乗り越えるOptium開発 〜
algoartis
0
220
REALITY コマンド作成チュートリアル
nishiuriraku
0
120
七輪ライブラリー: Claude AI で作る Next.js アプリ
suneo3476
1
190
Носок на сок
bo0om
0
1.3k
読書シェア会 vol.4 『ダイナミックリチーミング 第2版』
kotaro666
0
110
Ruby で作る RISC-V CPU エミュレーター / RISC-V CPU emulator made with Ruby
hayaokimura
5
1.1k
知識0からカンファレンスやってみたらこうなった!
syossan27
5
260
ASP.NETアプリケーションのモダナイゼーションについて
tomokusaba
0
260
KANNA Android の技術的課題と取り組み
watabee
1
500
Boost Your Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
880
MySQL初心者が311個のカラムにNot NULL制約を追加していってALTER TABLEについて学んだ話
hatsu38
2
140
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
4 Signs Your Business is Dying
shpigford
183
22k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
What's in a price? How to price your products and services
michaelherold
245
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
RailsConf 2023
tenderlove
30
1.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Optimising Largest Contentful Paint
csswizardry
37
3.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
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