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
68
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
98
Web APIs 2019
orlando
0
150
Managing remote teams
orlando
0
72
How to be a Senior Software Engineer
orlando
0
150
Terraform Workshop
orlando
1
170
Infrastructure as Code with Terraform
orlando
0
310
Concurrencia, Paralelismo y el Event-loop
orlando
0
380
Talking Web Apps
orlando
0
120
Web Launchpad - Chelajs
orlando
0
240
Other Decks in Programming
See All in Programming
Python’s True Superpower
hynek
0
170
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
190
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
340
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
110
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
800
AI & Enginnering
codelynx
0
140
Oxlintはいいぞ
yug1224
5
1.4k
Gemini for developers
meteatamel
0
110
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
840
Rubyと楽しいをつくる / Creating joy with Ruby
chobishiba
0
160
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1.1k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
660
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Building AI with AI
inesmontani
PRO
1
720
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
780
Discover your Explorer Soul
emna__ayadi
2
1.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.3k
A better future with KSS
kneath
240
18k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
260
Measuring & Analyzing Core Web Vitals
bluesmoon
9
760
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
140
How to build a perfect <img>
jonoalderson
1
5.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