SHARE
TWEET

Untitled

a guest Sep 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var obj = {
  2.   a: 1,
  3.   print() {
  4.     console.log(this.a);
  5.   }
  6. }
  7.  
  8. obj.print();  // 1
  9.  
  10.  
  11.  
  12.  
  13. var fn = obj.print
  14.  
  15. window.fn();  // undefined
  16.  
  17.  
  18. ===
  19.  
  20. function ctx() {
  21.   this.somePropery = 1;
  22.  
  23.   console.log(this.somePropery); // 1
  24. }
  25.  
  26. ctx();
  27.  
  28.  
  29. ===
  30.  
  31. for (var i = 1; i < 10; i++) {
  32.     setTimeout(() => console.log(i), 10); //
  33. }
  34.  
  35.  
  36. ===
  37.  
  38. var obj = {
  39.     a: 1
  40. };
  41.  
  42. (function(obj) {
  43. ----------------------
  44.     // obj.a = 2;
  45.     obj = {
  46.         a: 2
  47.     };
  48. --------------------------
  49.  
  50. })(obj);
  51.  
  52. console.log(obj.a); //  1
  53.  
  54.  
  55. ===
  56.  
  57. var foo = 1;
  58. function bar() {
  59.      alert(foo); // 1
  60.     if (!foo) {
  61.         var foo = 10;
  62.     }
  63.     alert(foo); // 10
  64. }
  65. alert(foo); // 1
  66. bar();
  67.  
  68.  
  69. ===
  70.  
  71. (function() {
  72.     f(); // 1
  73.  
  74.     f = function() {
  75.         console.log(1);
  76.     }
  77. })()
  78.  
  79. function f() {
  80.     console.log(2);
  81. }
  82.  
  83. f(); // 2
  84.  
  85.  
  86. ===
  87.  
  88. const p1 = Promise.resolve(2);
  89. const p2 = Promise.reject(3);
  90. const p3 = Promise.resolve(4);
  91. ------------------------------------
  92. const promises = [p1, p2, p3];
  93. promises.map((item)=> item.catch(error)=>Promise.resolve(3));
  94. ------------------------------------
  95.  
  96. Promise.all(promises)
  97.     .then((results) => console.log(results));
  98.  
  99.  
  100. ===
  101.  
  102. setTimeout(() => console.log('log'), 10000);
  103.  
  104.  
  105.  
  106.  
  107.  
  108. ===
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. function sum() {
  116.  
  117. };
  118.  
  119. // Вызов sum с пустым аргументом должен вернуть сумму предыдущих вызовов
  120. sum(1)(2)(3)() // => 6
  121.  
  122.  
  123.  
  124.  
  125. function debounce(func, wait) {
  126.  
  127. };
  128. const fn = debounced(() = console.log('LOG!'), 300);
  129. fn();
  130. fn();
  131. fn(); // 'LOG!'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top