Created
March 15, 2018 10:01
-
-
Save JoanClaret/79f88537f12d3e5a90b776040bf927e3 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/rejunis
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
const asyncSum = (number) => new Promise(resolve => setTimeout(() => resolve(number * 2), 2000)) | |
asyncSum(2).then(response => asyncSum(response).then( response=> console.log(response))) | |
const trolo = async(num) => { | |
const x = await asyncSum(num) | |
const y = await asyncSum(num * 2) | |
return x + y | |
} | |
trolo(3).then(response => console.log('trolololo' + response)) | |
class Animal { | |
constructor(speed){ | |
this.speed = speed | |
} | |
speak(){ | |
} | |
run(){ | |
console.log('animal running at ' + this.speed) | |
} | |
} | |
class Gorilla extends Animal { | |
run(speed){ | |
console.log('gorilla walking at ' + speed) | |
} | |
} | |
const dog = new Animal(200) | |
dog.run() | |
const gori = new Gorilla() | |
gori.run(100) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const asyncSum = (number) => new Promise(resolve => setTimeout(() => resolve(number * 2), 2000)) | |
asyncSum(2).then(response => asyncSum(response).then( response=> console.log(response))) | |
const trolo = async(num) => { | |
const x = await asyncSum(num) | |
const y = await asyncSum(num * 2) | |
return x + y | |
} | |
trolo(3).then(response => console.log('trolololo' + response)) | |
class Animal { | |
constructor(speed){ | |
this.speed = speed | |
} | |
speak(){ | |
} | |
run(){ | |
console.log('animal running at ' + this.speed) | |
} | |
} | |
class Gorilla extends Animal { | |
run(speed){ | |
console.log('gorilla walking at ' + speed) | |
} | |
} | |
const dog = new Animal(200) | |
dog.run() | |
const gori = new Gorilla() | |
gori.run(100) | |
</script></body> | |
</html> |
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 asyncSum = (number) => new Promise(resolve => setTimeout(() => resolve(number * 2), 2000)) | |
asyncSum(2).then(response => asyncSum(response).then( response=> console.log(response))) | |
const trolo = async(num) => { | |
const x = await asyncSum(num) | |
const y = await asyncSum(num * 2) | |
return x + y | |
} | |
trolo(3).then(response => console.log('trolololo' + response)) | |
class Animal { | |
constructor(speed){ | |
this.speed = speed | |
} | |
speak(){ | |
} | |
run(){ | |
console.log('animal running at ' + this.speed) | |
} | |
} | |
class Gorilla extends Animal { | |
run(speed){ | |
console.log('gorilla walking at ' + speed) | |
} | |
} | |
const dog = new Animal(200) | |
dog.run() | |
const gori = new Gorilla() | |
gori.run(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment