wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Javascript Lesson 11 + 12

Total questions: 20

Worksheet time: 7mins

Name
Class
Date
1.

Trong javascript, object nào đại diện cho trang web

a)

document

b)

window

c)

location

d)

browser

2.

Phương thức nào để tìm element theo id

a)

getElementById()

b)

getElementsById

c)

getElementId

d)

getId

3.

Nếu dùng code này thì sẽ lấy ra cái gì?
document.querySelectororAll('.box');

a)

Lấy element cho class box đầu tiên

b)

Lấy element có id là box

c)

Lấy tất cả element có class là .box

d)

getElementByClassName

4.

Phương thức nào để thêm một element con

a)

appendChild()

b)

replaceChild()

c)

addChild()

d)

createChild()

5.

Muốn thêm một function khi một event xảy ra thì dùng phương thức nào?

a)

addEventListener

b)

createEvent

c)

addFunction

d)

addEvent

6.

Phương thức nào tìm kiếm element theo class

a)

getElementsByTagName

b)

getElementsByClassName

c)

getElementsByClass

d)

getElementByClassName

7.

Cái nào dưới đây là web storage?

a)

localStorage

b)

serverStorage

c)

webStorage

d)

dataStorage

8.

Muốn lưu dữ liệu thì sử dụng localStorage như thế nào?

a)

localStorage.setItem('abc')

b)

localStorage.setItem('name', 'abc')

c)

setLocal('name', 'abc')

d)

local.setItem('name')

9.

Muốn di chuyển sang trang khác thì dùng phương thức nào

a)

window.location.href

b)

window.assign()

c)

location.href

d)

window.link

10.

Phương thức nào để thực thi code lặp lại nhiều lần

a)

interval

b)

setInterval

c)

setTimeout

d)

setTime

11.

Arrow function khai bao như thế nào?

a)

const fName = () => {}

b)

function fName() {}

c)

const fName = function() {}

d)

const fName => () = {}

12.

Đoạn code sau hiển thị ra cái gì

const name = "MindX";
const str = ` hello, ${name}!
Welcome.`;

a)

hello, MindX!
Welcome.

b)

hello, MindX!Welcome.

c)

hello, MindX!,Welcome.

d)

Báo lỗi

13.

Muốn sử dụng module trong javascript thì file js cần có thuộc tính gì?

a)

type="javascript"

b)

type="defer"

c)

type="module"

d)

type="importer"

14.

Một module có thể có mấy giá trị mặc định khi export

a)

1

b)

2

c)

10

d)

bao nhiêu cũng đc

15.

Spread và Rest dùng dấu gì để sử dụng?

a)

( )

b)

. . .

c)

[ ]

d)

{ }

16.

Cho đoạn code sau:

const arr = [4, 5, 6];
const arr2 = [1, 2, 3];
let arrT = [...arr2, ...arr];

let [x, y] = [arrT[2], arrT[4]];
console.log(x, y);

a)

6, 2

b)

3, 5

c)

2, 4

d)

5, 1

17.

Muốn import các giá trị không phải mặc định của module thì dùng dấu gì?

a)

{ }

b)

[ ]

c)

không cần

d)

" "

18.

Hàm map dùng để làm gì?

a)

Có thể thay đổi phần tử

b)

Lọc các phần tử

c)

Xử lí logic để tạo 1 giá trị nào đó

19.

Hàm filter lọc phần tử thì cần phải trả về giá trị nào trong function?

a)

true / false

b)

0 / 1

c)

chuỗi

d)

phần tử đang duyệt

20.

Cho đoạn code sau:

const arr = [1, 2, 3, 4];

const func = (x, y, ...rest) => x + y

console.log(func(...arr));
->> Kết quả in ra là:

a)

3

b)

7

c)

10

d)

5