Skip to content

Instantly share code, notes, and snippets.

@JoanClaret
Created March 15, 2018 10:02
Show Gist options
  • Save JoanClaret/29f4efcb35ad1bab396565ac256aa06c to your computer and use it in GitHub Desktop.
Save JoanClaret/29f4efcb35ad1bab396565ac256aa06c to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/rejunis
<!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(){
console.log('speaking')
}
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)
gori.speak(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(){
console.log('speaking')
}
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)
gori.speak(100)
</script></body>
</html>
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(){
console.log('speaking')
}
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)
gori.speak(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment