Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Вопрос 1
- // Что будет выведено в консоль?
- setTimeout(() => console.log(1));
- Promise.resolve().then(() => console.log(2));
- console.log(3);
- // Ответ:
- // 3
- // 2
- // 1
- // Вопрос 2
- // Что выведется в консоль?
- Promise.resolve()
- .then(() => 1)
- .then(a => console.log(a))
- .then(b => console.log(b))
- .then(() => throw new Error())
- .catch(() => 1)
- .then(c => console.log(c));
- // Ответ:
- // 1
- // undefined
- // 1
- // Вопрос 3
- // Что выведется в консоль?
- console.log(1 && 2 && 3);
- console.log(1 || 2 || 3);
- // Ответ:
- // 3
- // 1
- // Вопрос 4
- // Что выведется в консоль?
- console.log([0,1][0,1]);
- // Ответ:
- // 1
- // Вопрос 5
- // Что выведется в консоль?
- (function a(a) {
- function a() {}
- var a = 1;
- console.log(a);
- })(2);
- (function a(a) {
- var a = 1;
- function a() {}
- console.log(a);
- })(2);
- // Ответ:
- // 1
- // 1
- // Вопрос 6
- // Написать такую функцию sum, чтобы console.log(sum(a)(b)(c)(и т.д.)(z)) выводило сумму a + b + ... + z.
- //
- // Пример для проверки:
- // console.log(sum(2)(3));
- // console.log(sum(1)(1));
- //
- // должно вывести:
- // 5
- // 2
- // Ответ:
- //
- // function sum(a) {
- // let value = a;
- //
- // let fn = b => {
- // value += b;
- // return fn;
- // };
- //
- // fn.toString = () => {
- // return value;
- // };
- //
- // return fn;
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement