Тест по JavaScript — Что будет в консоли?
Что выведет в консоль?
console.log(a);
var a = 10;
- 1. undefined
- 2. ReferenceError
- 3. 10
- 4. null
Что будет в консоли?
console.log(b);
let b = 10;
- 1. ReferenceError
- 2. undefined
- 3. null
- 4. 10
Что выведет следующий код?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}
- 1. 2 2 2
- 2. 0 1 2
- 3. 3 3 3
- 4. undefined undefined undefined
А что выведет теперь?
for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}
- 1. 0 1 2
- 2. 3 3 3
- 3. 2 2 2
- 4. undefined undefined undefined
Что будет в консоли?
var a = 10;
(function() {
var a = 20;
console.log(a);
})();
- 1. 10
- 2. 20
- 3. undefined
- 4. ReferenceError
Что будет выведено?
console.log(this);
(В глобальной области в браузере)
- 1. window
- 2. undefined
- 3. null
- 4. object
Что будет результатом?
console.log([] == ![]);
- 1. true
- 2. false
- 3. undefined
- 4. ReferenceError
Что будет в консоли?
console.log(typeof new Function());
- 1. function
- 2. object
- 3. undefined
- 4. string
Что выведет?
console.log('5' - true);
- 1. NaN
- 2. true
- 3. false
- 4. TypeError
Что будет выведено?
let a = 10;
{
let a = 20;
}
console.log(a);
- 1. undefined
- 2. ReferenceError
- 3. 10
- 4. null
Что вернёт сравнение?
console.log(null == undefined);
- 1. true
- 2. false
Что будет результатом?
console.log(null === undefined);
- 1. true
- 2. false
- 3. TypeError
Что выведет функция?
const obj = {
a: 2,
b: function() {
return this.a;
}
};
console.log(obj.b());
- 1. 2
- 2. 3
- 3. undefined
- 4. NaN
А что тут?
const obj = {
a: 3,
b: () => this.a
};
console.log(obj.b());
- 1. 4
- 2. 3
- 3. undefined
- 4. NaN
Что вернёт typeof?
console.log(typeof null);
- 1. string
- 2. number
- 3. boolean
- 4. object
Что будет в консоли?
function test() {
var x = 1;
}
console.log(x);
- 1. 1
- 2. undefined
- 3. ReferenceError
- 4. 2
Что покажет консоль?
console.log(typeof function() {});
- 1. undefined
- 2. function
- 3. ReferenceError
- 4. null
Что покажет консоль?
console.log({} === {});
- 1. false
- 2. true
- 3. undefined
- 4. ReferenceError
Что будет?
console.log(parseInt('0xff', 10));
- 1. 0
- 2. undefined
- 3. TypeError
- 4. 1
Что выведется?
console.log(1 + '1');
- 1. NaN
- 2. 11
- 3. 2
- 4. TypeError