Guest User

Untitled

a guest
Mar 23rd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. const asyncSum = (number) => new Promise(resolve => setTimeout(() => resolve(number * 2), 2000))
  12.  
  13.  
  14. asyncSum(2).then(response => asyncSum(response).then( response=> console.log(response)))
  15.  
  16.  
  17. const trolo = async(num) => {
  18. const x = await asyncSum(num)
  19. const y = await asyncSum(num * 2)
  20. return x + y
  21. }
  22.  
  23. trolo(3).then(response => console.log('trolololo' + response))
  24.  
  25.  
  26. class Animal {
  27. constructor(speed){
  28. this.speed = speed
  29. }
  30.  
  31. speak(){
  32. console.log('speaking')
  33. }
  34.  
  35. run(){
  36. console.log('animal running at ' + this.speed)
  37. }
  38. }
  39.  
  40. class Gorilla extends Animal {
  41. run(speed){
  42. console.log('gorilla walking at ' + speed)
  43. }
  44. }
  45.  
  46.  
  47. const dog = new Animal(200)
  48. dog.run()
  49.  
  50. const gori = new Gorilla()
  51. gori.run(100)
  52. gori.speak(100)
  53. </script>
  54.  
  55.  
  56.  
  57. <script id="jsbin-source-javascript" type="text/javascript">const asyncSum = (number) => new Promise(resolve => setTimeout(() => resolve(number * 2), 2000))
  58.  
  59.  
  60. asyncSum(2).then(response => asyncSum(response).then( response=> console.log(response)))
  61.  
  62.  
  63. const trolo = async(num) => {
  64. const x = await asyncSum(num)
  65. const y = await asyncSum(num * 2)
  66. return x + y
  67. }
  68.  
  69. trolo(3).then(response => console.log('trolololo' + response))
  70.  
  71.  
  72. class Animal {
  73. constructor(speed){
  74. this.speed = speed
  75. }
  76.  
  77. speak(){
  78. console.log('speaking')
  79. }
  80.  
  81. run(){
  82. console.log('animal running at ' + this.speed)
  83. }
  84. }
  85.  
  86. class Gorilla extends Animal {
  87. run(speed){
  88. console.log('gorilla walking at ' + speed)
  89. }
  90. }
  91.  
  92.  
  93. const dog = new Animal(200)
  94. dog.run()
  95.  
  96. const gori = new Gorilla()
  97. gori.run(100)
  98. gori.speak(100)
  99. </script></body>
  100. </html>
Add Comment
Please, Sign In to add comment