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
| license: mit |
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
| async function getRedditJSON () { | |
| const response = await fetch('https://www.reddit.com/.json') | |
| return response.json() | |
| } | |
| getRedditJSON().then((data) => { | |
| console.log(data) | |
| }) |
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 getRedditJSON () { | |
| return fetch('https://www.reddit.com/.json') | |
| .then((response) => { | |
| return response.json() | |
| }) | |
| } | |
| getRedditJSON().then((data) => { | |
| console.log(data) | |
| }) |
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
| import React from 'react'; | |
| export interface SampleComponentProps { | |
| firstword: string, | |
| secondword: string | |
| } | |
| export interface SampleComponentState { | |
| phrase: string | |
| } |
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
| def sum(a=1,b=2,c=3): | |
| return a+b+c | |
| sum(b=5,a=10) |
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 sum({a = 1, b = 2, c = 3}) { | |
| return a + b + c | |
| } | |
| sum({b: 10, a: 5}) // 5 + 10 + 3 = 18 |
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 mockServerCall () { | |
| return new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| resolve({ | |
| 'status': 200, | |
| 'content-type': 'application/json', | |
| 'data' : { | |
| dataOfInterest: 42 | |
| } | |
| }) |
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 userSettings = {nightMode: true, fontSize: 'large'} | |
| const { | |
| nightMode = false, | |
| language = 'en', | |
| fontSize = 'normal' | |
| } = userSettings | |
| console.log(nightMode) // true | |
| console.log(language) // 'en' |
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 sumThreeNumbers(num1, num2, num3) { | |
| console.log([num1, num2, num3]); //[4,6,10] | |
| return num1 + num2 + num3; | |
| } | |
| const numbers = [4,6,10]; | |
| console.log(sumThreeNumbers(...numbers)); // 20 |
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 sumThreeNumbers(num1, num2, num3) { | |
| console.log([num1, num2, num3]); //[4,6,10] | |
| return num1 + num2 + num3; | |
| } | |
| const numbers = [4,6,10]; | |
| console.log(sumThreeNumbers(...numbers)); //20 |
NewerOlder