wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Perintah di javascript yang berfungsi untuk memberikan suatu informasi ke pengguna melalui jendela dialog dengan tombol Ok dan cancel adalah 

a)

prompt

b)

confirm

c)

dialog

d)

write

2.

Berikut adalah cara pembuatan array yang benar di javascript 

a)

mahasiswa = [‘Rini’,’Aldi’,’Acep’,’Putra’]

b)

mahasiswa = {‘Rini’,’Aldi’,’Acep’,’Putra’} 

c)

mahasiswa = (‘Rini’,’Aldi’,’Acep’,’Putra’)

d)

mahasiswa = ‘Rini’,’Aldi’,’Acep’,’Putra’

3.

Berikut adalah jenis-jenis array di javascript, kecuali

a)

Array Numerik

b)

Array Assosiatif

c)

Array Boolean

d)

Array Campuran

4.

Berikut ini dalah contoh event yang sering digunakan, kecuali 

a)

Onload

b)

Onclick

c)

Onchange

d)

Ontime

5.

Javascript memiliki beberapa tipe data seperti berikut, kecuali

a)

List

b)

Numerik

c)

String

d)

Boolean

6.

Perintah di javascript yang berfungsi untuk menampilkan data/informasi dalam bentuk POP UP adalalah

a)

Alert()

b)

Show()

c)

Write()

d)

Pop_up()

7.

Perl adalah singkatan dari 

a)

Practical Extraction and Reporting Language

b)

Practical Emulation and Reporting Language

c)

Principal Extraction and Reporting Language

d)

Principal Emulation and Reporting Language

8.

Which of the following keywords is used to define a variable in Javascript?

a)

Var

b)

Let

c)

Both A and B

d)

None of the above

9.

Which of the following methods is used to access HTML elements using Javascript?getElementbyId()

a)

getElementbyId()

b)

ElementsByClassName()

c)

Both A and B

d)

None of the above

10.

Which of the following methods can be used to display data in some form using Javascript?

a)

document. write()

b)

console.log()

c)

window.alert()

d)

All of the above

11.

What will be the output of the following code snippet?

<script type="text/javascript">

a = 5 + "9";

document.write(a);

</script>

a)

Compilation Error

b)

14

c)

Runtime Error

d)

59

12.

What will be the output of the following code snippet? 

<script type="text/javascript" language="javascript"> 

var a = "Scaler";

var result = a.substring(2, 4);

document.write(result);  

</script>

a)

Al

b)

Ale

c)

Cal

d)

Caler

13.

When the switch statement matches the expression with the given labels, how is the comparison done?

a)

Both the datatype and the result of the expression are compared

b)

Only the datatype of the expression is compared

c)

Only the value of the expression is compared 

d)

None of the above

14.

What will be the output of the following code snippet?

(function(){

  setTimeout(()=> console.log(1),2000);

  console.log(2);

  setTimeout(()=> console.log(3),0);

  console.log(4);

}) (); 

a)

1 2 3 4

b)

2 3 4 1

c)

2 4 3 1

d)

4 3 2 1

15.

What will be the output of the following code snippet?

function solve(arr, rotations){

if(rotations == 0) return arr;

for(let i = 0; i < rotations; i++){

let element = arr.pop();

arr.unshift(element);

}

return arr;

}

// solve([44, 1, 22, 111], 5);

a)

[111, 44, 1, 22]

b)

[44, 1, 22, 111]

c)

[111, 44, 1, 22]

d)

[1, 22, 111, 44]