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
You don't know JavaScript
Search
C1nde
October 03, 2015
Programming
0
180
You don't know JavaScript
C1nde
October 03, 2015
Tweet
Share
Other Decks in Programming
See All in Programming
ドメイン・ファーストで考える問題解決に役立つモデル設計 / Domain First Model Design
suzushin54
1
1.5k
コミュニティに参加したことで起きた変化
ohmori_yusuke
3
130
Material 3で Material 2ぽい見た目にする
numeroanddev
2
250
Open Source Swiftc Workshop
kitasuke
1
290
Open Source Swift Workshop - Foundation and first party libraries
ikesyo
0
270
MySQL のインデックスの種類をおさらいしよう! / overviewing indexes in MySQL
okashoi
0
180
受託開発でGitLab CI を活用していく
xiombatsg
1
130
WasmOS: Wasmを実行する自作Microkernel
riru
0
380
The Future of C++ Interoperability: Insights from Porting a Game to Swift
teamhimeh
0
290
どうしてこうなった命名集 ~🔥編~ / OOC 2024 LT
pictiny
4
2.9k
クソコード動画『カプセル化 Mk-II』 で考える 上手くカプセル化できない理由 / encapsulation2
minodriven
11
8.1k
DDD, necessary but insufficient: physical design principles for microservices
cer
PRO
0
2.2k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
57
3.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
257
12k
Building Effective Engineering Teams - LeadDev
addyosmani
25
1.8k
Keith and Marios Guide to Fast Websites
keithpitt
407
22k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
Embracing the Ebb and Flow
colly
78
4.1k
Pencils Down: Stop Designing & Start Developing
hursman
115
11k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
8
8.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
1.9k
How GitHub (no longer) Works
holman
301
140k
What the flash - Photography Introduction
edds
64
11k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Transcript
You don’t know JavaScript @C1nde
None
>>> study[0] simple math
>>> [] + [] ""
>>> [] + [] "" >>> {} + {} NaN
>>> [] + [] "" >>> {} + {} NaN
>>> [] + {} "[object Object]"
>>> [] + [] "" >>> {} + {} NaN
>>> [] + {} "[object Object]" >>> {} + [] 0
>>> study[1] Boolean
>>> if (true) { console.log('Will be printed'); } >>> if
(false) { console.log('Will not be printed'); }
>>> if (new Boolean(false)) { console.log('hmmmm'); } hmm
>>> if (new Boolean(false)) { console.log('hmmmm'); } hmm >>> if
(Boolean(false)) { console.log('as expected'); }
>>> study[2] NaN
>>> isNaN(new Date()); false >>> isNaN(new Date('notADate')); true
>>> isNaN(null); false
>>> isNaN(null); false >>> isNaN(undefined); true
>>> isNaN(null); false >>> isNaN(undefined); true >>> undefined == NaN;
false
>>> isNaN(null); false >>> isNaN(undefined); true >>> undefined == NaN;
false >>> NaN == NaN; false
>>> study[3] Object
>>> var o = {}; >>> typeof o "object"
>>> var o = {}; >>> typeof o "object" >>>
o instanceof Object true
>>> typeof null "object"
>>> typeof null "object" >>> null instanceof Object false
>>> study[3] Object^W Null
>>> study[4] RegEx
>>> var lowerCaseOnly = /^[a-z]+$/;
>>> var lowerCaseOnly = /^[a-z]+$/; >>> lowerCaseOnly.test('a'); true >>> lowerCaseOnly.test('A');
false >>> lowerCaseOnly.test(''); false
>>> var lowerCaseOnly = /^[a-z]+$/; >>> lowerCaseOnly.test(null); true >>> lowerCaseOnly.test(undefined);
true >>> lowerCaseOnly.test(); true
>>> study[5] String
>>> 'a string' === 'a string' true
>>> 'a string' === 'a string' true >>> new String('a
string') === 'a string' false
>>> 'a string' === 'a string' true >>> new String('a
string') === 'a string' false >>> String('a string') === 'a string' true
>>> study[6] String & RegEx
>>> var address = 'http://storage. com/gifs/picture.jpg'; >>> address.match('.gif');
>>> var address = 'http://storage. com/gifs/picture.jpg'; >>> address.match('.gif'); /gif
>>> study[7] Object
>>> var obj = { its: 1, an: 2, obj:
3 }; >>> obj.its = null; >>> obj.an = undefined; >>> delete obj.obj;
>>> for(var item in obj) { if (obj.hasOwnProperty(item)) { console.log(item,
obj[item]); } } its null an undefined
>>> study[8] prototype
>>> var obj = {}; >>> var proto = Object.prototype;
>>> proto.isPrototypeOf(obj); false >>> Object.isPrototypeOf(obj); false
>>> var obj = new Object(); >>> var proto =
Object.prototype; >>> proto.isPrototypeOf(obj); false >>> Object.isPrototypeOf(obj); false
>>> var obj = {}; >>> var proto = Object.prototype;
>>> proto === Object.getPrototypeOf (obj); true
>>> study[9] ???
>>> undefined == null; true
[~] > cat check.coffee obj = prop: value if obj.prop?
console.log obj.prop [~] > coffee -b -p check.coffee var obj; obj = { prop: value }; if (obj.prop != null) { console.log(obj.prop); }
THANKS