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 doNothing(obj) { | |
return obj ? obj : obj | |
} | |
function doSomethingButNothingStill(obj) { | |
if (obj) { | |
obj = obj | |
} | |
return obj ? obj : obj | |
} |
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 doNothing(obj) { | |
return obj ? obj : obj | |
} | |
const result = doNothing({ name: 'Bob' }) |
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
{ | |
"game1": { | |
"lakers": 80, | |
"celtics": 80, | |
"overtime": { | |
"lakers": 96, | |
"celtics": 116 | |
} | |
}, | |
"game2": { |
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 doubleTheNums(obj) { | |
const keys = Object.keys(obj) | |
for (let index = 0; index < keys.length; index++) { | |
const key = keys[index] | |
const value = obj[key] | |
if (typeof value === 'number') { | |
obj[key] = obj[key] * 2 | |
} else if (value && typeof value === 'object') { | |
doubleTheNums(obj[key]) |
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 doubleTheNums(obj) { | |
const keys = Object.keys(obj) | |
for (let index = 0; index < keys.length; index++) { | |
const key = keys[index] | |
const value = obj[key] | |
if (typeof value === 'number') { | |
obj[key] = obj[key] * 2 | |
} else if (value && typeof value === 'object') { | |
doubleTheNums(obj[key]) |
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
{ | |
"game1": { | |
"lakers": 80, | |
"celtics": 80, | |
"overtime": { | |
"lakers": 48, | |
"celtics": 58 | |
} | |
}, | |
"game2": { |
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 doubleTheNums(obj) { | |
const keys = Object.keys(obj) | |
for (let index = 0; index < keys.length; index++) { | |
const key = keys[index] | |
const innerObj = obj[key] | |
const innerObjKeys = Object.keys(innerObj) | |
for (let innerIndex = 0; innerIndex < innerObjKeys.length; innerIndex++) { | |
const innerObjKey = innerObjKeys[innerIndex] | |
const innerObjKeyValue = innerObj[innerObjKey] |
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 append(str, modify = (s) => s) { | |
return `hello ${modify(str)}` | |
} | |
function capitalize(value) { | |
return value.toUpperCase() | |
} | |
const result = append('boss', capitalize) // 'hello BOSS' |
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 f = console.log | |
const g = (str) => `Hello, ${str}` | |
const sayWord = (x) => f(g(x)) | |
sayWord('bryan') // "Hello, bryan |
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
class SomeElement<T> { | |
private element: T | |
constructor(element: T) { | |
this.element = element | |
} | |
getElement() { | |
return this.element | |
} |