This file contains 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 dog = { | |
age: 4, | |
name: 'Ronni' | |
} | |
dog.age = 6 // OK | |
dog = {} // ERROR |
This file contains 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 standard() { | |
return 'Rock' | |
} | |
const arrowLike = () => 'Rock' |
This file contains 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 dog = { | |
name: 'Ronni', | |
age: 4, | |
talk: function() { | |
retun `my name is ${this.name}` | |
} | |
} | |
// if you have some variables around | |
const name = 'Ronni' |
This file contains 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 data = fetch('http://something.com') | |
.then(result => result.json()) |
This file contains 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 Dog = (age, name) => ({ | |
age, | |
name, | |
talk: function() { | |
... | |
} | |
}) |
This file contains 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 procesData = ({ someProp, otherProp }) => { | |
... | |
} |
This file contains 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
cosnt one = { | |
a: 1, | |
b: 2 | |
} | |
const two = { | |
c: 2, | |
d: 3 | |
} |
This file contains 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 create = (proto, props) => | |
Object.assign(Object.create(proto), props) | |
const Vector2D = (x, y) => create({ | |
}, { | |
x, | |
y, | |
length: Math.hypot(x, y) | |
} | |
) |
This file contains 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
... | |
scaleBy (factor) { | |
return Vector2D(x * factor, y * factor) | |
}, | |
negate () { | |
return this.scaleBy(-1) | |
}, | |
normalize () { | |
return this.scaleBy(1 / this.length) | |
} |
This file contains 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
... | |
add ({ x, y }) { | |
return Vector2D(this.x + x, this.y + y) | |
}, | |
subtract ({ x, y }) { | |
return Vector2D(this.x - x, this.y - y) | |
} | |
... |
OlderNewer