Advertisement
the0938

HRQuesions

Aug 1st, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Вопрос 1
  2. // Что будет выведено в консоль?
  3.  
  4. setTimeout(() => console.log(1));
  5. Promise.resolve().then(() => console.log(2));
  6. console.log(3);
  7.  
  8.   // Ответ:
  9.   // 3
  10.   // 2
  11.   // 1
  12.  
  13. // Вопрос 2
  14. // Что выведется в консоль?
  15.  
  16. Promise.resolve()
  17.   .then(() => 1)
  18.   .then(a => console.log(a))
  19.   .then(b => console.log(b))
  20.   .then(() => throw new Error())
  21.   .catch(() => 1)
  22.   .then(c => console.log(c));
  23.  
  24.   // Ответ:
  25.   // 1
  26.   // undefined
  27.   // 1
  28.  
  29. // Вопрос 3
  30. // Что выведется в консоль?
  31.  
  32. console.log(1 && 2 && 3);
  33. console.log(1 || 2 || 3);
  34.  
  35.   // Ответ:
  36.   // 3
  37.   // 1
  38.  
  39. // Вопрос 4
  40. // Что выведется в консоль?
  41.  
  42. console.log([0,1][0,1]);
  43.  
  44.   // Ответ:
  45.   // 1
  46.  
  47. // Вопрос 5
  48. // Что выведется в консоль?
  49.  
  50. (function a(a) {
  51.   function a() {}
  52.   var a = 1;
  53.   console.log(a);
  54. })(2);
  55.  
  56. (function a(a) {
  57.   var a = 1;
  58.   function a() {}
  59.   console.log(a);
  60. })(2);
  61.  
  62.   // Ответ:
  63.   // 1
  64.   // 1
  65.  
  66. // Вопрос 6
  67. // Написать такую функцию sum, чтобы console.log(sum(a)(b)(c)(и т.д.)(z)) выводило сумму a + b + ... + z.
  68. //
  69. // Пример для проверки:
  70. // console.log(sum(2)(3));
  71. // console.log(sum(1)(1));
  72. //
  73. // должно вывести:
  74. // 5
  75. // 2
  76.  
  77.   // Ответ:
  78.   //
  79.   // function sum(a) {
  80.   //   let value = a;
  81.   //
  82.   //   let fn = b => {
  83.   //     value += b;
  84.   //     return fn;
  85.   //   };
  86.   //
  87.   //   fn.toString = () => {
  88.   //     return value;
  89.   //   };
  90.   //
  91.   //   return fn;
  92.   // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement