This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logAndReturnIt( | |
valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction: null, | |
): null { | |
console.log(typeof valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction) | |
return valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction | |
} | |
logAndReturnIt(null) // valid | |
logAndReturnIt(5) // invalid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const greeting = 'Good morning' | |
logAndReturnIt(greeting) // logs 'Good morning' | |
logAndReturnIt('cat') // logs 'cat' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logAndReturnIt( | |
valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction: string, | |
): string { | |
console.log(typeof valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction) | |
return valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@filterMales // This is the decorator | |
class MyClass { | |
constructor(children) { | |
this.children = children | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Frog(name) { | |
this.name = name | |
} | |
Frog.prototype.getTeeths = function() { | |
return 2 | |
} | |
Frog.prototype.lick = function(target) { | |
console.log(`I'm going lick you, ${target.name}. You better taste delicious`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function withToad(frog) { | |
frog.getTeeths = function() { | |
return 0 | |
} | |
} | |
const mikeTheFrog = new Frog('mike') | |
withToad(mikeTheFrog) | |
console.log(mikeTheFrog.getTeeths()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Toad(name) { | |
Frog.call(this, name) | |
this.getTeeths = function() { | |
return 0 | |
} | |
} | |
const kellyTheToad = new Toad('kelly') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Theme() {} | |
Theme.prototype.createStylesheet = function() { | |
return { | |
header: { | |
color: '#333', | |
fontStyle: 'italic', | |
fontFamily: 'Roboto, sans-serif', | |
}, | |
background: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"header": { | |
"color": "#333", | |
"fontStyle": "italic", | |
"fontFamily": "Roboto, sans-serif" | |
}, | |
"background": { "backgroundColor": "#fff" }, | |
"button": { "backgroundColor": "#fff", "color": "#333" }, | |
"color": "#fff" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bloodTheme(originalTheme) { | |
const originalStylesheet = originalTheme.createStylesheet() | |
originalTheme.createStylesheet = function() { | |
return { | |
name: 'blood', | |
...originalStylesheet, | |
header: { | |
...originalStylesheet.header, | |
color: '#fff', |