❓Что будет на выходе?
Ответ:true
JavaScript test | ChatGPT
function recursivePalindromeCheck(str) {
if (str.length <= 1) {
return true;
}
return str[0] === str[str.length - 1] && recursivePalindromeCheck(str.slice(1, -1));
}
const result = recursivePalindromeCheck("radar");
console.log(result);Ответ:
JavaScript test | ChatGPT
🧩Что будет на выходе?
Ответ:8
JavaScript test | ChatGPT
function recursiveFibonacci(n) {
return n <= 1 ? n : recursiveFibonacci(n - 1) + recursiveFibonacci(n - 2);
}
const result = recursiveFibonacci(6);
console.log(result);Ответ:
JavaScript test | ChatGPT
🧠Что будет на выходе?
Ответ:15
JavaScript test | ChatGPT
function asyncSum(arr) {
return arr.reduce(async (acc, num) => (await acc) + num, Promise.resolve(0));
}
async function computeTotal() {
const result = await asyncSum([1, 2, 3, 4, 5]);
console.log(result);
}
computeTotal();Ответ:
JavaScript test | ChatGPT
🔥Что будет на выходе?
Ответ:1
JavaScript test | ChatGPT
var foo = {};
var bar = Object.create(foo);
foo.a = 1;
console.log(bar.a);Ответ:
JavaScript test | ChatGPT
❓Что будет на выходе?
Ответ:true
JavaScript test | ChatGPT
function Animal() {}
const dog = new Animal();
console.log(dog.constructor === Animal);Ответ:
JavaScript test | ChatGPT
🔨Что будет на выходе?
Ответ:false
JavaScript test | ChatGPT
function Shape() {}
function Circle(radius) {}
Circle.prototype = Object.create(Shape.prototype);
const shape = new Shape();
console.log(shape instanceof Circle);Ответ:
JavaScript test | ChatGPT
❗️Что будет на выходе?
Ответ:false
JavaScript test | ChatGPT
function Animal() {}
function Dog() {}
Dog.prototype = Object.create(Animal.prototype);
const rover = new Dog();
console.log(rover.hasOwnProperty('constructor'));Ответ:
JavaScript test | ChatGPT
🧠Что будет на выходе?
Ответ:true, true, false, true
JavaScript test | ChatGPT
function Shape() {}
function Circle(radius) {
this.radius = radius;
}
Circle.prototype = Object.create(Shape.prototype);
Circle.prototype.constructor = Circle;
const shape = new Shape();
const circle = new Circle(5);
console.log(circle instanceof Circle);
console.log(circle instanceof Shape);
console.log(shape instanceof Circle);
console.log(shape instanceof Shape);Ответ:
JavaScript test | ChatGPT
❓Что будет на выходе?
Ответ:2
JavaScript test | ChatGPT
var x = 1;
function changeX() { x = 2; }
changeX();
console.log(x);
Ответ:
JavaScript test | ChatGPT
🔥Что будет на выходе?
Ответ:heo word
JavaScript test | ChatGPT
const string = "hello world";
const result = string.replace(/l/g, "");
console.log(result);
Ответ:
JavaScript test | ChatGPT
🧩Что будет на выходе?
Ответ:a1b2c3
JavaScript test | ChatGPT
const obj = { a: 1, b: 2, c: 3 };
let result = "";
for (const [key, value] of Object.entries(obj)) {
result += key + value;
}
console.log(result);Ответ:
JavaScript test | ChatGPT
🧠Что будет на выходе?
Ответ:true
JavaScript test | ChatGPT
const array = [
{ name: 'John', score: 80 },
{ name: 'Jane', score: 95 },
{ name: 'Doe', score: 88 },
];
const result = array.every(obj => obj.score >= 80);
console.log(result);
Ответ:
JavaScript test | ChatGPT
❗️Что будет на выходе?
Ответ:3
JavaScript test | ChatGPT
const a = [1, 2, 3];
const b = a.slice(0, 2).push(4);
console.log(b);
Ответ:
JavaScript test | ChatGPT
❔Что будет на выходе?
Ответ:true true
JavaScript test | ChatGPT
function Person() {}
var person = new Person();
console.log(person instanceof Person);
console.log(person instanceof Object);Ответ:
JavaScript test | ChatGPT
🧩Что будет на выходе?
Ответ:42
JavaScript test | ChatGPT
function X() {}
X.prototype.getValue = function() {
return this.value;
};
function Y() {
this.value = 42;
}
Y.prototype = Object.create(X.prototype);
Y.prototype.constructor = Y;
var y = new Y();
console.log(y.getValue());Ответ:
JavaScript test | ChatGPT
🔨Что будет на выходе?
Ответ:true true
JavaScript test | ChatGPT
function Animal(){
this.type = "animal"
}
function Dog(){
this.name = "dog"
}
Dog.prototype = new Animal()
var PavlovPet = new Dog();
console.log(PavlovPet.__proto__ === Dog.prototype)
console.log(Dog.prototype.__proto__ === Animal.prototype)Ответ:
JavaScript test | ChatGPT
❔Что будет на выходе?
Ответ:[1, 2, 3]
JavaScript test | ChatGPT
function getArr() {
return Array.from(arguments);
}
const result = getArr(...[1, 2, 3]);
console.log(result);Ответ:
JavaScript test | ChatGPT
❗️Что будет на выходе?
Ответ:1 1 2 3
JavaScript test | ChatGPT
function* gen() {
yield *[1,1];
yield 2;
yield 3;
}
const generator = gen();
console.log(generator.next().value);
console.log(generator.next().value);
for (const value of generator) {
console.log(value);
}Ответ:
JavaScript test | ChatGPT
🧩Что будет на выходе?
Ответ:2
JavaScript test | ChatGPT
function A() {}
A.prototype.value = 1;
function B() {}
B.prototype = new A();
B.prototype.value = 2;
var b = new B();
console.log(b.value);Ответ:
JavaScript test | ChatGPT