❓Что будет на выходе?
Ответ:function function 60 84
JavaScript test | #JavaScript & Max
const curry = (fn) => {
const arity = fn.length;
return function curried(...args) {
if (args.length >= arity) {
return fn(...args);
}
return (...moreArgs) => curried(...args, ...moreArgs);
};
};
const volume = (l, w, h) => l * w * h;
const curriedVolume = curry(volume);
const withLength5 = curriedVolume(5);
const withLength5Width3 = withLength5(3);
console.log(typeof withLength5);
console.log(typeof withLength5Width3);
console.log(withLength5Width3(4));
console.log(curriedVolume(2)(6)(7));
Ответ:
JavaScript test | #JavaScript & Max
❓Что будет на выходе?
Ответ:
{ a: 1, b: 3, c: 4 }
JavaScript test | #JavaScript & Max
const obj1 = { a: 1, b: 2 };
const obj2 = { b: 3, c: 4 };
const mergedObj = { ...obj1, ...obj2 };
console.log(mergedObj);
Ответ:
JavaScript test | #JavaScript & Max
❓Что будет на выходе?
Ответ:-256 -256
JavaScript test | #JavaScript & Max
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const pipe = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
const double = x => x * 2;
const addTen = x => x + 10;
const square = x => x * x;
const negate = x => -x;
const transform1 = compose(negate, square, addTen, double);
const transform2 = pipe(double, addTen, square, negate);
const val = 3;
console.log(transform1(val), transform2(val));
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе:
Ответ:
[ false, true, true ]
JavaScript test | #JavaScript & Max
const arr = [3, 8, 12];
const even = (elem) => elem % 2 === 0;
console.log(arr.map(even));
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе?
Ответ:[2, 4, 6, 10, 11]
JavaScript test | #JavaScript & Max
function* range(start, end) {
while (start < end) {
yield start++;
}
}
function* evens(iter) {
for (const val of iter) {
if (val % 2 === 0) yield val;
}
}
function* take(n, iter) {
let count = 0;
for (const val of iter) {
if (count++ >= n) return;
yield val;
}
}
function* pipeline() {
yield* take(3, evens(range(1, 20)));
yield* take(2, range(10, 15));
}
const result = [...pipeline()];
console.log(result);
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе?
Ответ:not configured
JavaScript test | #JavaScript & Max
const user = {
profile: {
name: 'Alice',
settings: {
notifications: {
email: true,
sms: false
}
}
},
getPreference(type) {
return this.profile?.settings?.notifications?.[type] ?? 'not configured';
}
};
const admin = {
profile: {
name: 'Admin',
settings: null
},
getPreference: user.getPreference
};
console.log(admin.getPreference('email'));
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе?
Ответ:1 7 3 4 6 5 2
JavaScript test | #JavaScript & Max
async function test() {
console.log('1');
setTimeout(() => {
console.log('2');
}, 0);
await Promise.resolve();
console.log('3');
new Promise(resolve => {
console.log('4');
resolve();
}).then(() => {
console.log('5');
});
console.log('6');
}
test();
console.log('7');
Ответ:
JavaScript test | #JavaScript & Max
❓Что будет на выходе?
Ответ:
Error: undeclaredVariable is nit defined
JavaScript test | #JavaScript & Max
'use strict';
function strictModeExample() {
undeclaredVariable = 10;
try {
console.log(undeclaredVariable);
} catch (e) {
console.log('Error:', e.message);
}
}
strictModeExample();
Ответ:
Error: undeclaredVariable is nit defined
JavaScript test | #JavaScript & Max
❗️Что будет на выходе?
Ответ:1 7 3 4 6 5 2
JavaScript test | #JavaScript & Max
async function test() {
console.log('1');
setTimeout(() => {
console.log('2');
}, 0);
await Promise.resolve();
console.log('3');
new Promise(resolve => {
console.log('4');
resolve();
}).then(() => {
console.log('5');
});
console.log('6');
}
test();
console.log('7');
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе:
Ответ:world@ | HELLO
JavaScript test | #JavaScript & Max
const str = " Hello, World! ";
const result = str
.trim()
.split(", ")
.map((word, i) => {
if (i % 2 === 0) return word.toUpperCase();
return word.toLowerCase().replace("!", "@");
})
.reverse()
.join(" | ");
console.log(result);
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе:
Ответ:
true
JavaScript test | #JavaScript & Max
function Animal(name) {
this.name = name;
}
Animal.prototype.speak = function() {
return `${this.name} makes a noise`;
};
function Dog(name) {
Animal.call(this, name);
}
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
Dog.prototype.speak = function() {
return `${this.name} barks`;
};
const animal = new Animal('Animal');
const dog = new Dog('Rex');
console.log(dog instanceof Animal);
Ответ:
JavaScript test | #JavaScript & Max