Skip to content

Instantly share code, notes, and snippets.

function logAndReturnIt(
valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction: null,
): null {
console.log(typeof valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction)
return valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction
}
logAndReturnIt(null) // valid
logAndReturnIt(5) // invalid
const greeting = 'Good morning'
logAndReturnIt(greeting) // logs 'Good morning'
logAndReturnIt('cat') // logs 'cat'
function logAndReturnIt(
valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction: string,
): string {
console.log(typeof valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction)
return valueThatIsGoingToBeLoggedAndReturnedFromAUselessFunction
}
@filterMales // This is the decorator
class MyClass {
constructor(children) {
this.children = children
}
}
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`)
function withToad(frog) {
frog.getTeeths = function() {
return 0
}
}
const mikeTheFrog = new Frog('mike')
withToad(mikeTheFrog)
console.log(mikeTheFrog.getTeeths())
function Toad(name) {
Frog.call(this, name)
this.getTeeths = function() {
return 0
}
}
const kellyTheToad = new Toad('kelly')
function Theme() {}
Theme.prototype.createStylesheet = function() {
return {
header: {
color: '#333',
fontStyle: 'italic',
fontFamily: 'Roboto, sans-serif',
},
background: {
{
"header": {
"color": "#333",
"fontStyle": "italic",
"fontFamily": "Roboto, sans-serif"
},
"background": { "backgroundColor": "#fff" },
"button": { "backgroundColor": "#fff", "color": "#333" },
"color": "#fff"
}
function bloodTheme(originalTheme) {
const originalStylesheet = originalTheme.createStylesheet()
originalTheme.createStylesheet = function() {
return {
name: 'blood',
...originalStylesheet,
header: {
...originalStylesheet.header,
color: '#fff',