Slide 1

Slide 1 text

@stefanjudis I didn't know that!

Slide 2

Slide 2 text

My first job interview

Slide 3

Slide 3 text

“ We're running a Magento shop combined with a CouchDB and a Frontend application with a Prototype/ jQuery mix.

Slide 4

Slide 4 text

“ We're running a Magento shop combined with a CouchDB and a Frontend application with a Prototype/ jQuery mix.

Slide 5

Slide 5 text

“ We're running a Magento shop combined with a CouchDB and a Frontend application with a Prototype/ jQuery mix.

Slide 6

Slide 6 text

“ We're running a Magento shop combined with a CouchDB and a Frontend application with a Prototype/ jQuery mix. I didn't say that I didn't know most of these technologies...

Slide 7

Slide 7 text

... which lead to enormous stress.

Slide 8

Slide 8 text

8 years later

Slide 9

Slide 9 text

The dangerous knowledge comparison

Slide 10

Slide 10 text

What I think others know What I know

Slide 11

Slide 11 text

Web Development

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

You can't know everything!

Slide 15

Slide 15 text

“ Don’t Compare Your Behind-The-Scenes With Everyone's Highlight Reel. by Tara Hunt

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Know where to look for information

Slide 18

Slide 18 text

The learning journey 
 won't end.

Slide 19

Slide 19 text

TIL: ... (Today I learned: ...)

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

But then I learned it's deprecated...

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Twitter is neither a bookmarking nor documentation tool!

Slide 24

Slide 24 text

Write it down! Quick'n'dirty!

Slide 25

Slide 25 text

My learnings in 2 years (a random list in no particular order) (not always useful)

Slide 26

Slide 26 text

NaNNaNNaN NaNNaN

Slide 27

Slide 27 text

parseInt('Hello world', 10)

Slide 28

Slide 28 text

parseInt('Hello world', 10) NaN

Slide 29

Slide 29 text

parseInt('Hello world', 10) NaN === NaN false

Slide 30

Slide 30 text

isNaN(NaN); // true

Slide 31

Slide 31 text

isNaN(NaN); // true isNaN(undefined); // true isNaN({}); // true isNaN(true); // false isNaN(null); // false isNaN(37); // false

Slide 32

Slide 32 text

isNaN(NaN); // true isNaN(undefined); // true isNaN({}); // true isNaN(true); // false isNaN(null); // false isNaN(37); // false function myIsNaN(value) { return value !== value; }

Slide 33

Slide 33 text

isNaN(NaN); // true isNaN(undefined); // true isNaN({}); // true isNaN(true); // false isNaN(null); // false isNaN(37); // false myIsNaN(NaN); // true myIsNaN(undefined); // false myIsNaN({}); // false myIsNaN(true); // false myIsNaN(null); // false myIsNaN(37); // false

Slide 34

Slide 34 text

isNaN(NaN); // true isNaN(undefined); // true isNaN({}); // true isNaN(true); // false isNaN(null); // false isNaN(37); // false myIsNaN(NaN); // true myIsNaN(undefined); // false myIsNaN({}); // false myIsNaN(true); // false myIsNaN(null); // false myIsNaN(37); // false Number.isNaN(NaN); // true Number.isNaN(undefined); // false Number.isNaN({}); // false Number.isNaN(true); // false Number.isNaN(null); // false Number.isNaN(37); // false

Slide 35

Slide 35 text

isNaN(NaN); // true isNaN(undefined); // true isNaN({}); // true isNaN(true); // false isNaN(null); // false isNaN(37); // false myIsNaN(NaN); // true myIsNaN(undefined); // false myIsNaN({}); // false myIsNaN(true); // false myIsNaN(null); // false myIsNaN(37); // false Number.isNaN(NaN); // true Number.isNaN(undefined); // false Number.isNaN({}); // false Number.isNaN(true); // false Number.isNaN(null); // false Number.isNaN(37); // false Object.is(NaN, NaN); // true Object.is(undefined, NaN); // false Object.is({}, NaN); // false Object.is(true, NaN); // false Object.is(null, NaN); // false Object.is(37, NaN); // false

Slide 36

Slide 36 text

Object.is? === + SPECIAL HANDLING OF NaN, -0, +0

Slide 37

Slide 37 text

Object.is? Object.is(-0, 0); // false Object.is(NaN, NaN); // true SameValue Comparison

Slide 38

Slide 38 text

['foo', 123, true, undefined, NaN].indexOf(NaN) ['foo', 123, true, undefined, NaN].includes(NaN) true ['foo', 123, true, undefined, -0].includes(0) true SameValueZero Comparison -1

Slide 39

Slide 39 text

Abstract Equality Comparison Equality comparison and sameness == Strict Equality Comparison ===, indexOf, ... SameValueZero includes, ... SameValue Object.is, ...

Slide 40

Slide 40 text

developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness

Slide 41

Slide 41 text

Should I (force) push it?

Slide 42

Slide 42 text

$ history | grep amend 53 git co -p --amend index.html 69 git co -p --amend 71 git co -p --amend content/blueprints 1538 git co -p --amend 1540 git co -p --amend migration-tests 1542 git co -p --amend migration-tests 1545 git co -p --amend test_app.py 1627 git co -p --amend 1842 git co --amend 1845 git co --amend 1941 git co --amend 2273 git co -p --amend ...

Slide 43

Slide 43 text

$ git co -p --amend index.html $ git push -f origin some-feature

Slide 44

Slide 44 text

$ git co -p --amend index.html $ git push -f origin some-feature It's very easy to overwrite remote changes with force pushing!

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

developer.atlassian.com/blog/2015/04/force-with-lease/

Slide 47

Slide 47 text

Process substitution

Slide 48

Slide 48 text

Process substitution $ bash <(curl -s https://codecov.io/bash)

Slide 49

Slide 49 text

“ Process substitution allows a process’s input or output to be referred to using a filename.

Slide 50

Slide 50 text

$ echo <(ls .) /dev/fd/11

Slide 51

Slide 51 text

$ cat <(ls .) functions.sh .zshrc ...

Slide 52

Slide 52 text

$ node <(echo 'console.log("foo")') foo

Slide 53

Slide 53 text

$ node <(pbpaste) foo

Slide 54

Slide 54 text

$ node <(pbpaste) foo console.log("foo") But then I learned you can pipe into Node.js

Slide 55

Slide 55 text

$ node <(pbpaste) foo

Slide 56

Slide 56 text

$ pbpaste | node foo

Slide 57

Slide 57 text

Break zooming with one line

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

body { font-size: 2vw; }

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

body { font-size: calc(1vw + 1em); }

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Stylesheets do not only block rendering

Slide 64

Slide 64 text

app.css START RENDER

Slide 65

Slide 65 text

var script = document.createElement('script'); script.src = "analytics.js"; document.getElementsByTagName('head')[0].appendChild(script);

Slide 66

Slide 66 text

var script = document.createElement('script'); script.src = "analytics.js"; document.getElementsByTagName('head')[0].appendChild(script); app.css analytics.js

Slide 67

Slide 67 text

var script = document.createElement('script'); script.src = "analytics.js"; document.getElementsByTagName('head')[0].appendChild(script); 
 
 app.css analytics.js

Slide 68

Slide 68 text

WAT!!!

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

{ 'ü': 'foo', 'ü': 'bar', '': 'baz', '': 'wat!' }

Slide 71

Slide 71 text

{ 'ü': 'foo', 'u\u0308': 'bar', '': 'baz', '': 'wat!' }

Slide 72

Slide 72 text

{ 'ü': 'foo', 'u\u0308': 'bar', '': 'baz', '\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC66': 'wat!' }

Slide 73

Slide 73 text

“ Two IdentifierName that are canonically equivalent according to the Unicode standard are not equal unless they are represented by the exact same sequence of code units.

Slide 74

Slide 74 text

“ Two IdentifierName that are canonically equivalent according to the Unicode standard are not equal unless they are represented by the exact same sequence of code units.

Slide 75

Slide 75 text

Unicode is powerful and very fascinating (and scary)

Slide 76

Slide 76 text

https://www.fileformat.info/info/unicode/char/202e/index.htm

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

"Logical" string comparisons

Slide 79

Slide 79 text

'aBcD' === 'abcd'

Slide 80

Slide 80 text

'aBcD' === 'abcd' // false

Slide 81

Slide 81 text

'aBcD' === 'abcd' // false 'ábcd' === 'abcd'

Slide 82

Slide 82 text

'aBcD' === 'abcd' // false 'ábcd' === 'abcd' // false

Slide 83

Slide 83 text

'aBcD' === 'abcd' // false 'ábcd' === 'abcd' // false 'Price 2€' > 'Price 1€'

Slide 84

Slide 84 text

'aBcD' === 'abcd' // false 'ábcd' === 'abcd' // false 'Price 2€' > 'Price 1€' // true

Slide 85

Slide 85 text

'aBcD' === 'abcd' // false 'ábcd' === 'abcd' // false 'Price 2€' > 'Price 1€' // true 'Price 20€' > 'Price 3€'

Slide 86

Slide 86 text

'aBcD' === 'abcd' // false 'ábcd' === 'abcd' // false 'Price 2€' > 'Price 1€' // true 'Price 20€' > 'Price 3€' // false

Slide 87

Slide 87 text

localCompare 'aBcD'.localeCompare('abcd', undefined, { sensitivity: 'base' }) // 0 'ábcd'.localeCompare('abcd', undefined, { sensitivity: 'base' }) // 0

Slide 88

Slide 88 text

localCompare a ≠ b, a = á, a = A 'aBcD'.localeCompare('abcd', undefined, { sensitivity: 'base' }) // 0 'ábcd'.localeCompare('abcd', undefined, { sensitivity: 'base' }) // 0

Slide 89

Slide 89 text

localCompare 'Price 2€'.localeCompare('Price 3€', undefined, { numeric: true }) // -1 'Price 3€'.localeCompare('Price 3€', undefined, { numeric: true }) // 0 'Price 23€'.localeCompare('Price 3€', undefined, { numeric: true }) // 1

Slide 90

Slide 90 text

localCompare 'Price 2€'.localeCompare('Price 3€', undefined, { numeric: true }) // -1 'Price 3€'.localeCompare('Price 3€', undefined, { numeric: true }) // 0 'Price 23€'.localeCompare('Price 3€', undefined, { numeric: true }) // 1 "1" < "2" < "10"

Slide 91

Slide 91 text

How to center elements

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

.center { display: flex; align-items: center; justify-content: center; }

Slide 94

Slide 94 text

.center { display: flex; align-items: center; justify-content: center; } .center-using-grid { display: grid; align-items: center; justify-items: center; }

Slide 95

Slide 95 text

.center { display: flex; align-items: center; justify-content: center; } .center-using-grid { display: grid; place-items: center; }

Slide 96

Slide 96 text

.center { display: flex; align-items: center; justify-content: center; } .center-using-grid { display: grid; place-items: center; } 2 declarations!

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

developer.mozilla.org/en-US/docs/Web/CSS/place-items place-items support

Slide 99

Slide 99 text

Querying the DOM is not equal querying the DOM

Slide 100

Slide 100 text

  • foo
  • bar
  • baz
document.querySelectorAll('li'); // NodeList(3) [li, li, li]

Slide 101

Slide 101 text

  • foo
  • bar
  • baz
document.querySelectorAll('li'); // NodeList(3) [li, li, li] document.getElementsByTagName('li'); // HTMLCollection(3) [li, li, li]

Slide 102

Slide 102 text

  • foo
  • bar
  • baz
NodeList(3) HTMLCollection(3)

Slide 103

Slide 103 text

  • foo
  • bar
  • baz
  • wat
NodeList(3) HTMLCollection(4)

Slide 104

Slide 104 text

  • foo
  • bar
  • baz
  • wat
NodeList(3) HTMLCollection(4) There are live and static element collections

Slide 105

Slide 105 text

document.querySelectorAll // static NodeList

Slide 106

Slide 106 text

document.querySelectorAll // static NodeList element.childNodes // live NodeList

Slide 107

Slide 107 text

document.querySelectorAll // static NodeList element.childNodes // live NodeList element.children // (live) HTMLCollection

Slide 108

Slide 108 text

document.querySelectorAll // static NodeList element.childNodes // live NodeList element.children // (live) HTMLCollection document.getElementsByTagName // (live) HTMLCollection

Slide 109

Slide 109 text

www.stefanjudis.com/blog/accessing-the-dom-is-not-equal-accessing-the-dom

Slide 110

Slide 110 text

WAT!!! (part 2)

Slide 111

Slide 111 text

Fooo

Some more information

#foo:hover { background: DeepSkyBlue; }

Slide 112

Slide 112 text

No content

Slide 113

Slide 113 text

“ Document languages may define additional ways in which an element can match :hover. For example, [HTML5] defines a labeled control element as matching :hover when its label is hovered.

Slide 114

Slide 114 text

“ Document languages may define additional ways in which an element can match :hover. For example, [HTML5] defines a labeled control element as matching :hover when its label is hovered.

Slide 115

Slide 115 text

kizu.ru/en/blog/label-to-input/

Slide 116

Slide 116 text

Regular expressions

Slide 117

Slide 117 text

const regex = /Jane.Smith/; regex.test('Jane Smith'); // true regex.test('Jane\nSmith'); // false

Slide 118

Slide 118 text

const regex = /Jane.Smith/; regex.test('Jane Smith'); // true regex.test('Jane\nSmith'); // false '.' doesn't actually match all characters!

Slide 119

Slide 119 text

const regex = /Jane.Smith/; regex.test('Jane Smith'); // true regex.test('Jane\nSmith'); // false

Slide 120

Slide 120 text

const regex = /Jane.Smith/s; regex.test('Jane Smith'); // true regex.test('Jane\nSmith'); // true

Slide 121

Slide 121 text

github.com/tc39/proposal-regexp-dotall-flag

Slide 122

Slide 122 text

* * use with Babel dotall flag support * *

Slide 123

Slide 123 text

const regex = /Jane.Smith/;

Slide 124

Slide 124 text

const regex = /(Jane|John).(Smith|Miller)/; 'John Smith'.match(regex); // [ "John Smith", "John", "Smith" ]

Slide 125

Slide 125 text

const regex = /(Jane|John).(Smith|Miller)/; 'John Smith'.match(regex); // [ "John Smith", "John", "Smith" ]

Slide 126

Slide 126 text

const regex = /(?:Jane|John).(Smith|Miller)/; 'John Smith'.match(regex); // [ "John Smith","Smith" ]

Slide 127

Slide 127 text

const regex = /(?:Jane|John).(Smith|Miller)/; 'John Smith'.match(regex); // [ "John Smith","Smith" ] There are non-capturing groups in JavaScript

Slide 128

Slide 128 text

Why we won't have element queries

Slide 129

Slide 129 text

Why we (probably) won't have element queries

Slide 130

Slide 130 text

No content

Slide 131

Slide 131 text

.mod img { display: block; margin: 0 auto; width: 100%; max-width: 250px; }

Slide 132

Slide 132 text

.mod img { display: block; margin: 0 auto; width: 100%; max-width: 250px; } .mod:media( min-width: 425px ) img { float: left; width: 30%; max-width: 9999px; }

Slide 133

Slide 133 text

No content

Slide 134

Slide 134 text

.box { width: 1200px; }

Slide 135

Slide 135 text

.box { width: 1200px; }

Slide 136

Slide 136 text

.box { width: 1200px; } .box:media(min-width: 1200px) { width: 1000px; }

Slide 137

Slide 137 text

.box { width: 1200px; } .box:media(min-width: 1200px) { width: 1000px; }

Slide 138

Slide 138 text

.box { width: 1200px; } .box:media(min-width: 1200px) { width: 1000px; }

Slide 139

Slide 139 text

.box { width: 1200px; } .box:media(min-width: 1200px) { width: 1000px; }

Slide 140

Slide 140 text

.box { width: 1200px; } .box:media(min-width: 1200px) { width: 1000px; }

Slide 141

Slide 141 text

.box { width: 1200px; } .box:media(min-width: 1200px) { width: 1000px; } And now, we're in a loop...

Slide 142

Slide 142 text

https://css-tricks.com/selectors-that-depend-on-layout/

Slide 143

Slide 143 text

Checking for an existing class

Slide 144

Slide 144 text

Slide 145

Slide 145 text

Slide 146

Slide 146 text

const elem = querySelector('.component'); if( elem.classList.contains('is-active') && elem.classList.contains('is-awesome') ) { /* ... */ }

Slide 147

Slide 147 text

const elem = querySelector('.component'); if( elem.matches('.is-active') && elem.matches('.is-awesome') ) { /* ... */ }

Slide 148

Slide 148 text

const elem = querySelector('.component'); if(elem.matches('.is-active.is-awesome')) { /* ... */ }

Slide 149

Slide 149 text

“ The Element.matches() method returns true if the element would be selected by the specified selector string; otherwise, returns false.

Slide 150

Slide 150 text

“ The Element.matches() method returns true if the element would be selected by the specified selector string; otherwise, returns false.

Slide 151

Slide 151 text

background-repeat has other options than repeat

Slide 152

Slide 152 text

.box { }

Slide 153

Slide 153 text

.box { background-image: url(https://.../jsunconf.svg); }

Slide 154

Slide 154 text

.box { background-image: url(https://.../jsunconf.svg); background-repeat: repeat; }

Slide 155

Slide 155 text

.box { background-image: url(https://.../jsunconf.svg); background-repeat: round; }

Slide 156

Slide 156 text

.box { background-image: url(https://.../jsunconf.svg); background-repeat: space; }

Slide 157

Slide 157 text

min-content/ max-content

Slide 158

Slide 158 text

Merel van der Woude Creative director bij Butterfly Works

Slide 159

Slide 159 text

Merel van der Woude Creative director

Slide 160

Slide 160 text

Merel van der Woude Creative director, overall great person, loves books

Slide 161

Slide 161 text

Merel van der Woude Creative director, overall great person, loves books

Slide 162

Slide 162 text

Merel van der Woude Creative director, overall great person, loves books That's not possible, is it?

Slide 163

Slide 163 text

Merel van der Woude Creative director

Slide 164

Slide 164 text

Merel van der Woude Creative director

h2 { width: min-content; min-width: 0; max-width: 100%; }

Slide 165

Slide 165 text

Merel van der Woude Creative director

h2 { width: min-content; min-width: 0; max-width: 100%; } h2 span { width: max-content; max-width: 100%; }

Slide 166

Slide 166 text

https://codepen.io/maddesigns/pen/YNXvMz

Slide 167

Slide 167 text

Dry package configuration

Slide 168

Slide 168 text

{ "name": "my-package", "scripts": { "lint": "eslint ./src/*", "test": "jest ./src/*" } }

Slide 169

Slide 169 text

{ "name": "my-package", "config": { "src": "./src/*" }, "scripts": { "lint": "eslint $npm_package_config_src", "test": "jest $npm_package_config_src" } }

Slide 170

Slide 170 text

{ "name": "my-package", "config": { "src": "./src/*" }, "scripts": { "lint": "eslint $npm_package_config_src", "test": "jest $npm_package_config_src" } } Avoid duplication

Slide 171

Slide 171 text

{ "foo": "bar" "scripts": { "start": "node index.js" } }

Slide 172

Slide 172 text

{ "foo": "bar" "scripts": { "start": "node index.js" } } // index.js console.log(process.env.npm_package_foo); // 'bar'

Slide 173

Slide 173 text

And finally...

Slide 174

Slide 174 text

function f() { try { return 'A'; } finally { return 'B'; } } f(); // ? 'B'

Slide 175

Slide 175 text

function g() { try { throw new Error('Foo'); } catch( e ) { return 'A'; } finally { return 'B'; } } f(); // ? 'B'

Slide 176

Slide 176 text

function h() { try { throw new Error('Foo'); } finally { return 'B'; } } h(); //? 'B' (without throwing exception)

Slide 177

Slide 177 text

function i() { try { throw new Error('Foo'); } catch( e ) { throw new Error('Bar'); return 'A'; } finally { return 'B'; } } i(); //? 'B' (without throwing exception)

Slide 178

Slide 178 text

“ If the finally block returns a value, this value becomes the return value of the entire try-catch-finally production, regardless of any return statements in the try and catch blocks.

Slide 179

Slide 179 text

“ If the finally block returns a value, this value becomes the return value of the entire try-catch-finally production, regardless of any return statements in the try and catch blocks.

Slide 180

Slide 180 text

77 documented learnings

Slide 181

Slide 181 text

www.stefanjudis.com/today-i-learned

Slide 182

Slide 182 text

It only takes 
 10 minutes

Slide 183

Slide 183 text

No content

Slide 184

Slide 184 text

Did I improve? Like, at all? Oh yes!!!

Slide 185

Slide 185 text

I'm building my own knowledge base!

Slide 186

Slide 186 text

Celebrate learnings!

Slide 187

Slide 187 text

Huh!
 I didn't know that!

Slide 188

Slide 188 text

THANKS FOR LISTENING! @stefanjudis www.stefanjudis.com my-links.online/i-didnt-know

Slide 189

Slide 189 text

THANKS FOR LISTENING! @stefanjudis www.stefanjudis.com my-links.online/i-didnt-know Yes, I bought my-links.online

Slide 190

Slide 190 text

THANKS FOR LISTENING! @stefanjudis www.stefanjudis.com my-links.online/i-didnt-know