Guest User

Untitled

a guest
Mar 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 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.  
  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. </script>
  53.  
  54.  
  55.  
  56. <script id="jsbin-source-javascript" type="text/javascript">const asyncSum = (number) => new Promise(resolve => setTimeout(() => resolve(number * 2), 2000))
  57.  
  58.  
  59. asyncSum(2).then(response => asyncSum(response).then( response=> console.log(response)))
  60.  
  61.  
  62. const trolo = async(num) => {
  63. const x = await asyncSum(num)
  64. const y = await asyncSum(num * 2)
  65. return x + y
  66. }
  67.  
  68. trolo(3).then(response => console.log('trolololo' + response))
  69.  
  70.  
  71. class Animal {
  72. constructor(speed){
  73. this.speed = speed
  74. }
  75.  
  76. speak(){
  77.  
  78. }
  79.  
  80. run(){
  81. console.log('animal running at ' + this.speed)
  82. }
  83. }
  84.  
  85. class Gorilla extends Animal {
  86. run(speed){
  87. console.log('gorilla walking at ' + speed)
  88. }
  89. }
  90.  
  91.  
  92. const dog = new Animal(200)
  93. dog.run()
  94.  
  95. const gori = new Gorilla()
  96. gori.run(100)
  97. </script></body>
  98. </html>
Add Comment
Please, Sign In to add comment