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
let squared = 2 ** 2 // value of squared is 4 | |
, cubed = 2 ** 3 // value of cubed is 8 |
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
let squared = 2, | |
, cubed = 3 | |
squared **= 2 // same as: squared = squared * squared | |
cubed **= 3 // same as: cubed = cubed * cubed * cubed |
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
let data = { "King" : "Jon Snow", | |
"Queen" : "Daenerys Targaryen", | |
"Hand" : "Tyrion Lannister"} | |
console.log(Object.entries(data)) | |
> [["King","Jon Snow"],["Queen","Daenerys Targaryen"],["Hand","Tyrion Lannister"]] |
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
let data = { "King" : "Jon Snow", | |
"Queen" : "Daenerys Targaryen", | |
"Hand" : "Tyrion Lannister"} | |
console.log(Object.values(data)) | |
> ["Jon Snow","Daenerys Targaryen","Tyrion Lannister"] |
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
> 'a'.padStart(5, 'xy') | |
'xyxya' | |
> 'a'.padStart(4, 'xy') | |
'xyxa' | |
> '1234'.padStart(2, '#') | |
'1234' | |
> '###'.padStart(10, '0123456789') | |
'0123456###' | |
> 'a'.padStart(10) | |
' a' |
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
> 'a'.padEnd(5, 'xy') | |
'axyxy' | |
> 'a'.padEnd(4, 'xy') | |
'axyx' | |
> '1234'.padEnd(2, '#') | |
'1234' | |
> '###'.padEnd(10, '0123456789') | |
'###0123456' | |
> 'a'.padEnd(10) | |
'a ' |
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 obj = { | |
id: 123, | |
get bar() { return 'abc' }, | |
}; | |
console.log(Object.getOwnPropertyDescriptors(obj)); | |
> { id: | |
{ value: 123, | |
writable: true, | |
enumerable: true, |
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
// All the code snippets below are acceptable | |
let obj = { | |
first: 'Naruto', | |
last: 'Uzumaki', | |
} | |
let array = [ | |
'red', | |
'green', |
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
// Current syntax | |
function fetchJson(url) { | |
return fetch(url) | |
.then(request => request.text()) | |
.then(text => { | |
return JSON.parse(text); | |
}) | |
.catch(error => { | |
console.log(`ERROR: ${error.stack}`); | |
}); |
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
import numbers | |
import six | |
import numpy | |
import matplotlib.collections | |
from matplotlib import pyplot | |
# using example from | |
# http://nbviewer.ipython.org/github/dpsanders/matplotlib-examples/blob/master/colorline.ipynb |
OlderNewer