JavaScript test
10.2K subscribers
3.05K photos
6 videos
4.44K links
Проверка своих знаний по языку JavaScript.

Ссылка: @Portal_v_IT

Сотрудничество: @oleginc, @tatiana_inc

Канал на бирже: telega.in/c/js_test

РКН: clck.ru/3KHeYk
Download Telegram
❗️Что будет на выходе?

function* generatorQuiz() {
yield 1;
}

const generator = generatorQuiz();

setTimeout(() => console.log(generator.next().value), 0);

for (const value of generator) {
console.log(value);
}


Ответ: 1, undefined

JavaScript test | ChatGPT
🧩Что будет на выходе?

const obj = {
0: 'a',
1: 'b',
length: 2
};

const result = Array.from(obj);

console.log(result);


Ответ: ['a', 'b']

JavaScript test | ChatGPT
🧩Что будет на выходе?

function recursiveReverseString(str) {
return str === "" ? str : recursiveReverseString(str.substr(1)) + str[0];
}

const result = recursiveReverseString("hello");

console.log(result);


Ответ: "olleh"

JavaScript test | ChatGPT
Что будет на выходе?

function recursiveBinarySearch(arr, target, start = 0, end = arr.length - 1) {
if (start > end) {
return -1;
}

const mid = Math.floor((start + end) / 2);

if (arr[mid] === target) {
return mid;
} else if (arr[mid] < target) {
return recursiveBinarySearch(arr, target, mid + 1, end);
} else {
return recursiveBinarySearch(arr, target, start, mid - 1);
}
}

const result = recursiveBinarySearch([1, 2, 3, 4, 5, 6, 7, 8, 9], 6);

console.log(result);


Ответ: 5

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);



Ответ: true

JavaScript test | ChatGPT
🧩Что будет на выходе?

function recursiveFibonacci(n) {
return n <= 1 ? n : recursiveFibonacci(n - 1) + recursiveFibonacci(n - 2);
}

const result = recursiveFibonacci(6);

console.log(result);


Ответ:8

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();


Ответ: 15

JavaScript test | ChatGPT
🔥Что будет на выходе?

var foo = {};
var bar = Object.create(foo);

foo.a = 1;

console.log(bar.a);


Ответ: 1

JavaScript test | ChatGPT
Что будет на выходе?

function Animal() {}
const dog = new Animal();
console.log(dog.constructor === Animal);


Ответ: true

JavaScript test | ChatGPT
🔨Что будет на выходе?

function Shape() {}
function Circle(radius) {}
Circle.prototype = Object.create(Shape.prototype);
const shape = new Shape();
console.log(shape instanceof Circle);


Ответ: false

JavaScript test | ChatGPT
❗️Что будет на выходе?

function Animal() {}
function Dog() {}
Dog.prototype = Object.create(Animal.prototype);
const rover = new Dog();
console.log(rover.hasOwnProperty('constructor'));


Ответ: false

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);


Ответ: true, true, false, true

JavaScript test | ChatGPT
Что будет на выходе?

var x = 1;
function changeX() { x = 2; }
changeX();
console.log(x);


Ответ: 2

JavaScript test | ChatGPT
❗️Что будет на выходе?

console.log(typeof null);


Ответ: object

JavaScript test | ChatGPT
🔥Что будет на выходе?

const string = "hello world";
const result = string.replace(/l/g, "");
console.log(result);


Ответ: heo word

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);


Ответ: a1b2c3

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);


Ответ: true

JavaScript test | ChatGPT
❗️Что будет на выходе?

const a = [1, 2, 3];
const b = a.slice(0, 2).push(4);
console.log(b);


Ответ: 3

JavaScript test | ChatGPT
Что будет на выходе?

function Person() {}

var person = new Person();

console.log(person instanceof Person);
console.log(person instanceof Object);


Ответ: true true

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());


Ответ: 42

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)


Ответ: true true

JavaScript test | ChatGPT