250 Câu hỏi trắc nghiệm Javascript, CSS, HTML có đáp án - Phần 2
50 câu hỏi
for (biến = Giá trị đầu; Điều kiện; Giá trị tăng)
for (biến = Giá trị đầu; Giá trị tăng; điều kiện)
for (biến = Điều kiện; Giá trị tăng; Giá trị cuối)
Tất cả các dạng trên.
Chọn đáp án A
if (i != 5)
if i =! 5 then
if i <> 5
if (i <> 5)
Chọn đáp án A
var a = [1, 2, 3];
var b = [1, 2, 3];
var c = '1,2,3';
console.log(a == c);
console.log(b == c);
console.log(a == b);
true, true, false
true, true, true
true, false, false
false, false false
Chọn đáp án A
var a = [9];
var b = [10];
console.log(a == 9);
console.log(b == 10);
console.log(a < b);
true true true
false false false
true true false
false false true
Chọn đáp án C
let i = 0;
const arr = new Array(5);
arr.forEach(() => i++);
console.log(i);
0
1
4
5
Chọn đáp án A
function greatestNumberInArray(arr) {
let greatest = 0;
for (let i = 0; i < arr.length; i++) {
if (greatest < arr[i]) {
greatest = arr[i];
}
}
return greatest;
}
Yes
No
Chọn đáp án B
const arr = [1, 2, 3];
const a = arr.reduce(
(acc, el, i) => ({ ...acc, [el]: i }),
{}
);
const b = {};
for (let i = 0; i < arr.length; i++) {
b[arr[i]] = i;
}
a
b
Chọn đáp án B
const arr = [
x => x * 1,
x => x * 2,
x => x * 3,
x => x * 4
];
console.log(arr.reduce((agg, el) => agg + el(agg), 1));
1
60
100
120
Chọn đáp án D
const ar = [5, 1, 3, 7, 25];
const ar1 = ar;
console.log(ar1.sort());
([5, 25].indexOf(ar[1]) != -1 &&
console.log(ar.reverse())) ||
(ar[3] == 25 && console.log(ar));
console.log(ar1);
[1, 3, 5, 7, 25] [7, 5, 3, 25, 1] [1, 25, 3, 5, 7] [1, 25, 3, 5, 7]
[1, 25, 3, 5, 7] [5,1,3,7,25]
[1, 25, 3, 5, 7] [7, 5, 3, 25, 1] [7, 5, 3, 25, 1] [7, 5, 3, 25, 1]
An error is thrown
Chọn đáp án C
const arr1 = ['a', 'b', 'c'];
const arr2 = ['b', 'c', 'a'];
console.log(
arr1.sort() === arr1,
arr2.sort() == arr2,
arr1.sort() === arr2.sort()
);
true true true
true true false
false false false
true false true
Chọn đáp án B
function ArrayBoolean() {
if ([] == true && [1] == true) return [true, true];
else if ([] == true && [1] == false) return [true, false];
else if ([] == false && [1] == true) return [false, true];
else return [false, false];
}ArrayBoolean();
[true, true]
[true, false]
[false, true]
[false, false
Chọn đáp án C
breed: 'Border Collie',
sound: 'Wooh',
getBreed: () => {
return this.breed;
},
getSound: function() {
return this.sound;
}
};
console.log(dog.getBreed(), dog.getSound());
Border Collie, Wooh
Border Collie, undefined
undefined, Wooh
undefined, undefined
Chọn đáp án C
const person = { name: 'duthaho' };
function sayHi(age) {
return `${this.name} is ${age}`;
}
console.log(sayHi.call(person, 69));
console.log(sayHi.bind(person, 69));
undefined is 69 duthaho is 69
function function
duthaho is 69 duthaho is 69
duthaho is 69 function
Chọn đáp án D
function withVar() {
const b = () => a;
var a = 24;
return b;
}
function withLet() {
const b = () => a;
let a = 24;
return b;
}
function changingValue() {
let a = 24;
const b = () => a;
a = 42;
return b;
}
undefined Error 42
24 Error 24
24 24 42
undefined Error 24
Chọn đáp án C
let a = new Date('2019,1,1').toLocaleDateString();
let b = new Date(2019, 1, 1).toLocaleDateString();
console.log(a, b);
1/1/2019 2/1/2019
1/1/2019 1/1/2019
Chọn đáp án A
console.log(fetch);
The fetch function
A reference error
It depends
Chọn đáp án C
const a = 0.1;
const b = 0.2;
const c = 0.3;
console.log(a + b === c);
True
False
Chọn đáp án B
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
const ti = new Person('du', 'ti');
const teo = Person('du', 'teo');
console.log(ti);
console.log(teo);
Person {firstName: "du", lastName: "ti"} undefined
Person {firstName: "du", lastName: "ti"} Person {firstName: "du", lastName:"teo"}'
Person {firstName: "du", lastName: "ti"} {}
Person {firstName: "du", lastName: "ti"} ReferenceError
Chọn đáp án A
bar();
var bar;
function bar() {
console.log('first');
}
bar = function () {
console.log('second');
};
bar();
foo();
function foo() {
console.log(1);
}
var foo = function () {
console.log(2);
};
function foo() {
console.log(3);
}
foo();
second first 1 3
first second 3 2
second first 3 3
first second 3 3
Chọn đáp án B
function sayHi() {
return (() => 0)();
}
console.log(typeof sayHi());
object
number
function
undefined
Chọn đáp án B
const a = {
stringField: 'Joe',
numberField: 123,
dateField: new Date('1995-12-17T03:24:00'),
nestedField: { field: 'Nested' }
};
const b = JSON.parse(JSON.stringify(a));
console.log(
a.stringField === b.stringField,
a.numberField === b.numberField,
a.dateField === b.dateField,
a.nestedField.field === b.nestedField.field
);
true true true true
true true true false
true true false true
false false false false
Chọn đáp án C
const notifications = 1;
console.log(
`You have ${notifications} notification${notifications !==
1 && 's'}`
);
You have 1 notification
You have 1 notifications
You have 1 notificationfalse
Chọn đáp án C
const compare = a => a === a;
console.log(compare(null));
console.log(compare(undefined));
console.log(compare(NaN));
console.log(compare([NaN]));
true true true true
true false true true
true true false true
true true false false
Chọn đáp án C
const n = 5;
console.log(1..n); // ?
[1, 2, 3, 4, 5]
undefined
Syntax error
Chọn đáp án B
const a = {
stringField: 'Joe',
nestedField: { field: 'Nested' },
functionField: () => 'aReturn'
};
const b = Object.assign({}, a);
b.stringField = 'Bob';
b.nestedField.field = 'Changed';
b.functionField = () => 'bReturn';
console.log(
a.stringField,
a.nestedField.field,
a.functionField()
);
Joe Nested aReturn
Bob Changed bReturn
Joe Changed aReturn
Bob Nested bReturn
Chọn đáp án C
const url = 'quiz.duthaho.com';
const { length: ln, [ln - 1]: domain = 'quiz' } = url
.split('.')
.filter(Boolean);
console.log(domain);
"quiz"
"duthaho"
"com"
undefined
Chọn đáp án C
const obj = { a: 'one', b: 'two', a: 'three' };
console.log(obj);
{a: "one", b: "two" }
{b: "two", a: "three" }
{a: "three", b: "two" }
{a: "three", b: "two" }
Chọn đáp án C
const user = {
name: 'lao Hac',
age: 69,
pet: {
type: 'cho',
name: 'vang'
}
};
Object.freeze(user);
user.pet.name = 'shiba';
console.log(user.pet.name);
shiba
vang
An error is thrown
Chọn đáp án A
const obj = {
1: 1,
2: 2,
3: 3
};
console.log(Object.keys(obj), Object.values(obj));
[1, 2, 3] ["1", "2", "3"]
["1", "2", "3"] [1, 2, 3]
["1", "2", "3"] ["1", "2", "3"]
Chọn đáp án B
const obj = { 1: 'a', 2: 'b', 3: 'c' };
const set = new Set([1, 2, 3, 4, 5]);
obj.hasOwnProperty('1');
obj.hasOwnProperty(1);
set.has('1');
set.has(1);
false true false true
false true true true
true true false true
true true true true
Chọn đáp án C
const a = {};
const b = { key: 'b' };
const c = { key: 'c' };
a[b] = 123;
a[c] = 456;
console.log(a[b]);
123
456
undefined
ReferenceError
Chọn đáp án B
const scrambled = {
2: 'e',
5: 'o',
1: 'h',
4: 'l',
3: 'l'
};
const result = Object.values(scrambled).reduce(
(agg, el) => agg + el,
''
);
console.log(result);
hello
eohll
Cả A, B đều đúng
Cả A, B đều sai
Chọn đáp án A
let b = '4';
console.log(b++ + 3, b);
44 4
8 5
7 5
43 5
Chọn đáp án C
console.log(1 < 2 < 3);
console.log(3 > 2 > 1);
true true
true false
false false
undefined undefined
Chọn đáp án B
HEAD, HTML, BODY
HEAD, TITLE, BODY
HEAD, BODY, HTML
HTML, HEAD, BODY
Chọn đáp án D
<HR>
<P>
<BR>
<PRE>
Chọn đáp án B
NAME
CLASS
HREF
ID
Chọn đáp án A
<PIC>
<IMG>
<IMAGE>
<PICTURE>
Chọn đáp án B
<ADDRESS>
<PRE>
<BLOCKQUOTE>
<AUTHOR>
Chọn đáp án A
<span>
<pre>
<blockquote>
<div>
Chọn đáp án A
<li>
<ul>
<lo>
<dl>
Chọn đáp án A
<color>
<font>
<fontstyle>
<fontsize>
Chọn đáp án C
<tr>
<td>
<table>
<th>
Chọn đáp án C
<tr>
<td>
<table>
<th>
Chọn đáp án A
Colspan
Align
Rowspan
Valign
Chọn đáp án C
Colspan
Align
Rowspan
Valign
Chọn đáp án D
<frame>
<noframe>
<ifframe>
<frameset>
Chọn đáp án C
<input type="text">
<input type ="hidden"
<input type="password"
<textarea>
Chọn đáp án A
dùng thẻ:
<input type="text">
<input type =" hidden"
<input type="password"
<textarea>
Chọn đáp án B
<input type= "text">
<input type ="radio"
<input type="checkbox"
<textarea>
Chọn đáp án C




