TGViewer
Channel Public Channel
JavaScript test

JavaScript test

@js_test

Проверка своих знаний по языку JavaScript.

Ссылка: @Portal_v_IT

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

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

РКН: clck.ru/3KHeYk
Subscribers
9.77K
Photos
3.1K
Videos
12
Links
4.7K
Recent Posts 19 shown
Post #6546 123
❗️Что будет на выходе?

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

Ответ: 1 7 3 4 6 5 2

JavaScript test | #JavaScript & Max
Post #6545 144
❗️Что будет на выходе?

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

Ответ: not configured

JavaScript test | #JavaScript & Max
Post #6544 145
❗️Что будет на выходе?

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

Ответ: [2, 4, 6, 10, 11]

JavaScript test | #JavaScript & Max
Post #6543 175
❗️Что будет на выходе:

const arr = [3, 8, 12];
const even = (elem) => elem % 2 === 0;

console.log(arr.map(even));

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


JavaScript test | #JavaScript & Max
Post #6542 181
Что будет на выходе?

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

Ответ: -256 -256

JavaScript test | #JavaScript & Max
Post #6541 182
Что будет на выходе?

const obj1 = { a: 1, b: 2 };
const obj2 = { b: 3, c: 4 };
const mergedObj = { ...obj1, ...obj2 };
console.log(mergedObj);

Ответ:
{ a: 1, b: 3, c: 4 }

JavaScript test | #JavaScript & Max
Post #6540 201
Что будет на выходе?

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

Ответ: function function 60 84

JavaScript test | #JavaScript & Max
Post #6537 226
Что будет на выходе?

const numbers = [1, 2, 3, 4, 5];

const result = numbers
.filter(n => n % 2 === 0)
.map(n => n * 2)
.reduce((acc, n) => acc + n, 0);

console.log(result);

Ответ:
12


JavaScript test | #JavaScript & Max
Post #6536 245
❗️Что будет на выходе:

const operations = {
add: (a, b) => a + b,
subtract: (a, b) => a - b,
multiply: (a, b) => a * b,
divide: (a, b) => b !== 0 ? a / b : null,
};

const pipeline = (...fns) => (value) => fns.reduce((acc, fn) => fn(acc), value);

const double = (x) => operations.multiply(x, 2);
const addTen = (x) => operations.add(x, 10);
const halve = (x) => operations.divide(x, 2);
const subtractThree = (x) => operations.subtract(x, 3);

const transform = pipeline(double, addTen, halve, subtractThree);

console.log(transform(5));

Ответ: 7

JavaScript test | #JavaScript & Max
Post #6535 262
❗️Что будет на выходе:

const numbers = [1, 3, 5, 7, 13];

const result = numbers.reduce((acc, val) => {
acc[val] = val * 2;
return acc;
}, {});

console.log(result);

Ответ: { '1': 2, '3': 6, '5': 10, '7': 14, '13': 26 }

JavaScript test | #JavaScript & Max
Post #6533 260
Что будет на выходе?

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

Ответ: -256 -256

JavaScript test | #JavaScript & Max
Post #6532 257
Что будет на выходе?

const obj1 = { a: 1, b: 2 };
const obj2 = { b: 3, c: 4 };
const mergedObj = { ...obj1, ...obj2 };
console.log(mergedObj);

Ответ:
{ a: 1, b: 3, c: 4 }

JavaScript test | #JavaScript & Max
Post #6530 274
16 сентября в Arena Breakout: Infinite выходит седьмой сезон — «Утопия»

Если не сталкивались с игрой: это бесплатный тактический шутер про вылазки за добычей. Заходишь на локацию со своим снаряжением, набираешь лут и пытаешься уйти живым. Погиб — потерял всё, что было с собой.

Что завозят в новом сезоне:

• Заражённая зона — три карты превращаются в биоопасные локации с ночью, туманом и ливнем, по ним бродят шесть видов мутантов. Другие игроки при этом никуда не делись
• Режим на выживание — отдельный PvE без риска: снаряжение с собой не берёшь и ничего не теряешь, просто отбиваешься от волн и открываешь усиления
• Торговец прямо в рейде — можно обменять припасы и разведданные или докупить снаряжение
• Два новых ствола, сезонные обвесы и переработанная стрельба: дальность выше, попадания в голову ощутимее
• На старте бесплатно выдают прокачиваемую сапёрную лопату, скины и билеты, а между игроками разыгрывают 200 000 очков

Игра бесплатная, качается в Steam, российский регион поддерживается → https://abi.go.link/2wzTb
Post #6529 259
Что будет на выходе?

const sym1 = Symbol('description');
const sym2 = Symbol('description');

const obj = {
[sym1]: 'value1',
[sym2]: 'value2'
};

console.log(obj[sym1]);

Ответ:
'value1'

JavaScript test | #JavaScript & Max
Post #6528 289
Что будет на выходе?

'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
Post #6526 260
Что будет на выходе?

var obj = {
a: 10,
b: 20
};

with (obj) {
var result = a + b;
}

console.log(result);

Ответ:
30


JavaScript test | #JavaScript & Max
Post #6525 287
❗️Что будет на выходе:

const promise1 = Promise.resolve('first');
const promise2 = new Promise(resolve => {
resolve('second');
});

const promise3 = Promise.resolve().then(() => 'third');

async function test() {
console.log('start');

const result1 = await promise1;
console.log(result1);

const result2 = await promise2;
console.log(result2);

const result3 = await promise3;
console.log(result3);

console.log('end');
}

test();

Ответ: start first second third end

JavaScript test | #JavaScript & Max
Post #6524 280
❗️Что будет на выходе?

function Device(name) {
this.name = name;
this.isOn = false;
}

Device.prototype.turnOn = function() {
this.isOn = true;
return `${this.name} is now on`;
};

function Smartphone(name, model) {
Device.call(this, name);
this.model = model;
}

Smartphone.prototype = Object.create(Device.prototype);
Smartphone.prototype.constructor = Smartphone;

Smartphone.prototype.turnOn = function() {
const result = Device.prototype.turnOn.call(this);
return `${result} (model: ${this.model})`;
};

const myPhone = new Smartphone('iPhone', '13 Pro');
console.log(myPhone.turnOn());

Ответ: iPhone is now on (model: 13 Pro)

JavaScript test | #JavaScript & Max
Post #6523 291
❗️Что будет на выходе:

const cache = new WeakMap();

function expensiveOperation(obj) {
if (cache.has(obj)) {
console.log('Cache hit!');
return cache.get(obj);
}

console.log('Computing result...');
const result = obj.value * 2;
cache.set(obj, result);
return result;
}

const user = { value: 42 };
expensiveOperation(user);
expensiveOperation(user);
expensiveOperation({ value: 42 });

Ответ: Computing result... Cache hit! Computing result...

JavaScript test | #JavaScript & Max
Older posts →

About this channel

How can I read @js_test without a Telegram account?
TGViewer shows the public web preview Telegram publishes for JavaScript test: recent posts, photos, videos and the subscriber count, with no app, login or account.
How many subscribers does JavaScript test have?
JavaScript test (@js_test) has 9.77K subscribers on Telegram, refreshed roughly every 30 minutes.
Does JavaScript test know I viewed it here?
No. Public channel previews carry no viewer identity, and TGViewer has no accounts or tracking of what you look up.
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →