wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Table of Contents - Beginner's Javascript Cheat Sheet

Total questions: 97

Worksheet time: 49mins

Name
Class
Date
1.

What is the purpose of 'Javascript Basics' in learning Javascript?

a)

To introduce fundamental concepts and syntax of Javascript.

b)

To teach advanced frameworks like React.

c)

To cover server-side programming with Node.js.

d)

To focus on mobile app development using Javascript.

2.

What are 'Variables' used for in Javascript?

a)

To store data values.

b)

To create functions.

c)

To display output on the screen.

d)

To define loops.

3.

What is an 'Array' in Javascript?

a)

A data structure used to store multiple values in a single variable.

b)

A function that returns a single value.

c)

A type of loop used for iteration.

d)

A keyword used to declare variables.

4.

Which of the following best describes 'Operators' in Javascript?

a)

Functions

b)

Symbols that perform operations on variables and values

c)

Loops

d)

Statements

5.

What is the main use of 'Functions' in Javascript?

a)

To group reusable code into blocks that can be called when needed.

b)

To store data permanently in the browser.

c)

To style web pages using CSS.

d)

To create database connections.

6.

What is the purpose of 'Loops' in Javascript?

a)

To execute a block of code repeatedly as long as a condition is true.

b)

To declare variables in Javascript.

c)

To create functions in Javascript.

d)

To import external libraries in Javascript.

7.

What do 'If - Else Statements' allow you to do in Javascript?

a)

To make decisions in code based on conditions.

b)

To create loops in code.

c)

To declare variables.

d)

To define functions.

8.

What are 'Strings' in Javascript?

a)

Sequences of characters used to represent text.

b)

Numbers used for calculations.

c)

Boolean values representing true or false.

d)

Objects containing key-value pairs.

9.

What are 'Regular Expressions' used for in Javascript?

a)

To store numbers

b)

To match patterns in strings

c)

To create loops

d)

To define functions

10.

What is the role of 'Numbers and Math' in Javascript?

a)

To perform mathematical operations and handle numeric data.

b)

To manage string concatenation and text formatting.

c)

To create and manipulate HTML elements.

d)

To handle user authentication and session management.

11.

What does 'Dealing with Dates' refer to in Javascript?

a)

Working with date and time values using built-in objects and methods.

b)

Handling string manipulation for user names.

c)

Managing arrays and their elements.

d)

Creating and styling HTML elements.

12.

What is a 'DOM Node' in Javascript?

a)

An object representing an element in the HTML document structure.

b)

A variable used to store JavaScript functions.

c)

A method for styling HTML elements.

d)

A type of JavaScript loop.

13.

What does 'Working with the Browser' mean in Javascript?

a)

Interacting with browser features and APIs, such as manipulating the DOM or handling events.

b)

Writing server-side code to manage databases.

c)

Creating graphics using the Canvas API only.

d)

Compiling JavaScript to machine code before execution.

14.

What are 'Events' in Javascript?

a)

Actions or occurrences that happen in the browser, which can be responded to using event handlers.

b)

Variables that store user input in Javascript.

c)

Functions that execute automatically when a page loads.

d)

Objects used to style HTML elements.

15.

What are 'Errors' in Javascript?

a)

Problems that occur during code execution, which can be handled using error handling techniques.

b)

Variables that store user input data.

c)

Functions that execute automatically when a page loads.

d)

Comments used to explain code logic.

16.

Which HTML tag is used to include JavaScript code in a web page?

a)

a)

myscript.js

b)

script.js

c)

external.js

d)

file.js

18.

Which symbol is used for single line comments in JavaScript?

a)

//

b)

/*

c)

#

19.

Which symbol is used for multi-line comments in JavaScript?

a)

//

b)

/* ... */

c)

d)

# ... #

20.

Fill in the blank: The following code declares a variable with a number value: var age = ____

a)

23

b)

"23"

c)

twenty-three

d)

null

21.

What is the value assigned to the variable 'a' in the following code? var a = "init"

a)

init

b)

start

c)

undefined

d)

null

22.

What is the result of the following operation? var b = 1 + 2 + 3

a)

6

b)

5

c)

7

d)

9

23.

What is the value of the variable 'c' in the following code? var c = true

a)

true

b)

false

c)

null

d)

undefined

24.

What is the value of the constant PI in the following code? const PI = 3.14

a)

3.14

b)

2.71

c)

1.62

d)

3.00

25.

What is the value of the 'firstName' property in the following object? var name = {firstName:"John", lastName:"Doe"}

a)

John

b)

Jane

c)

Michael

d)

David

26.

Which of the following is the correct way to define an object in Javascript?

a)

var person = {firstName:"John", lastName:"Doe", age:20, nationality:"German"};

b)

var person = [firstName:"John", lastName:"Doe", age:20, nationality:"German"];

c)

var person = "firstName:John, lastName:Doe, age:20, nationality:German";

27.

What is the value of the second element in the following array? var fruit = ["Banana", "Apple", "Pear"];

a)

Apple

b)

Banana

c)

Pear

d)

Orange

28.

Which array method would you use to join several arrays into one?

a)

concat()

b)

join()

c)

indexOf()

d)

lastIndexOf()

29.

Which array method returns the first position at which a given element appears in an array?

a)

concat()

b)

join()

c)

indexOf()

d)

lastIndexOf()

30.

Which array method combines elements of an array into a single string and returns the string?

a)

concat()

b)

join()

c)

indexOf()

d)

lastIndexOf()

31.

Which array method gives the last position at which a given element appears in an array?

a)

concat()

b)

join()

c)

indexOf()

d)

lastIndexOf()

32.

What does the '==' operator mean in Javascript?

a)

Not equal

b)

Equal to

c)

Greater than

d)

Less than

33.

Fill in the blank: The '===' operator in Javascript means _______.

a)

Equal value and equal type

b)

Equal value only

c)

Equal type only

d)

Assignment operator

34.

What does the '!=' operator mean in Javascript?

a)

Not equal

b)

Equal to

c)

Less than

d)

Greater than

35.

Fill in the blank: The '!==' operator in Javascript means _______.

a)

Not equal value or not equal type

b)

Equal value and equal type

c)

Not equal value but equal type

d)

Equal value or not equal type

36.

What does the '>' operator mean in Javascript?

a)

Less than

b)

Greater than

c)

Equal to

d)

Not equal

37.

What does the '<' operator mean in Javascript?

a)

Less than

b)

Greater than

c)

Equal to

d)

Not equal

38.

Fill in the blank: The '>=' operator in Javascript means _______.

a)

Greater than or equal to

b)

Less than or equal to

c)

Equal to

d)

Not equal to

39.

Fill in the blank: The '<=' operator in Javascript means _______.

a)

Less than or equal to

b)

Greater than or equal to

c)

Equal to

d)

Not equal to

40.

What does the '?' operator mean in Javascript?

a)

Logical and

b)

Ternary operator

c)

OR statement

d)

NOT

41.

Fill in the blank: The '&&' operator in Javascript means _______.

a)

Logical and

b)

Bitwise and

c)

Logical or

d)

Assignment

42.

Fill in the blank: The '||' operator in Javascript means _______.

a)

Logical or

b)

Logical and

c)

Bitwise or

d)

Assignment

43.

Fill in the blank: The '!' operator in Javascript means _______.

a)

Logical not

b)

Logical and

c)

Bitwise OR

d)

Increment

44.

What does the '&' operator mean in Javascript?

a)

A) AND statement

b)

B) OR statement

c)

C) NOT

d)

D) XOR

45.

What does the '|' operator mean in Javascript?

a)

AND statement

b)

OR statement

c)

NOT

d)

XOR

46.

Fill in the blank: The '~' operator in Javascript means _______.

a)

NOT

b)

AND

c)

OR

d)

XOR

47.

Fill in the blank: The '^' operator in Javascript means _______.

a)

XOR

b)

Exponentiation

c)

AND

d)

OR

48.

Fill in the blank: The '<<' operator in Javascript means _______.

a)

Left shift

b)

Right shift

c)

Bitwise AND

d)

Bitwise OR

49.

Fill in the blank: The '>>' operator in Javascript means _______.

a)

Right shift

b)

Left shift

c)

Bitwise AND

d)

Bitwise OR

50.

Fill in the blank: The '>>>' operator in Javascript means _______.

a)

Zero fill right shift

b)

Bitwise AND

c)

Left shift

d)

Bitwise OR

51.

Fill in the blank: In Javascript, a function is defined as function name(parameter1, parameter2, parameter3) { // what the function does }. What does this code define?

a)

A function

b)

A variable

c)

An array

d)

A loop

52.

What does alert() do in Javascript?

a)

Writes information to the browser console

b)

Opens a yes/no dialog

c)

Outputs data in an alert box

d)

Defines a function

53.

What does confirm() do in Javascript?

a)

Outputs data in an alert box

b)

Opens a yes/no dialog and returns true/false depending on user click

c)

Writes information to the browser console

d)

Defines a function

54.

What does console.log() do in Javascript?

a)

Outputs data in an alert box

b)

Opens a yes/no dialog

c)

Writes information to the browser console

d)

Defines a function

55.

Which JavaScript function writes directly to the HTML document?

a)

document.write()

b)

console.log()

c)

alert()

d)

window.open()

56.

Which JavaScript function creates a dialogue for user input?

a)

prompt()

b)

alert()

c)

console.log()

d)

confirm()

57.

Which JavaScript global function decodes a Uniform Resource Identifier (URI) created by encodeURI or similar?

a)

decodeURI()

b)

decodeURIComponent()

c)

parseURI()

d)

unescapeURI()

58.

Which JavaScript global function decodes a URI component?

a)

decodeURIComponent()

b)

encodeURIComponent()

c)

decodeURI()

d)

parseURI()

59.

Which JavaScript global function encodes a URI into UTF-8?

a)

encodeURI()

b)

decodeURI()

c)

escape()

d)

parseInt()

60.

Which JavaScript global function encodes a URI component into UTF-8?

a)

encodeURIComponent()

b)

decodeURIComponent()

c)

escape()

d)

encodeURI()

61.

Which JavaScript global function evaluates JavaScript code represented as a string?

a)

eval()

b)

parseInt()

c)

decodeURI()

d)

JSON.stringify()

62.

Which JavaScript global function determines whether a passed value is a finite number?

a)

isFinite()

b)

isNumber()

c)

isInteger()

d)

isFloat()

63.

Which JavaScript global function determines whether a value is NaN or not?

a)

isNaN()

b)

parseInt()

c)

isFinite()

d)

Number()

64.

Which JavaScript global function returns a number converted from its argument?

a)

Number()

b)

String()

c)

parseInt()

d)

Boolean()

65.

Which JavaScript global function parses an argument and returns a floating point number?

a)

parseFloat()

b)

parseInt()

c)

Number()

d)

toFixed()

66.

Which JavaScript global function parses its argument and returns an integer?

a)

parseInt()

b)

parseFloat()

c)

Number()

d)

toString()

67.

What is the most common way to create a loop in Javascript?

a)

while

b)

for

c)

do while

d)

break

68.

Which loop in Javascript executes at least once and performs a check at the end to see if the condition is met to execute again?

a)

for

b)

while

c)

do while

d)

continue

69.

Fill in the blank: The 'break' statement in Javascript is used to ________ and exit the cycle at certain conditions.

a)

stop

b)

continue

c)

repeat

d)

skip

70.

Fill in the blank: The 'continue' statement in Javascript is used to ________ parts of the cycle if certain conditions are met.

a)

skip

b)

repeat

c)

end

d)

execute

71.

Fill in the blank: In Javascript, the syntax for an if-else statement is: if (condition) { // what to do if condition is met } else { // what to do if condition is ________ }

a)

not met

b)

true

c)

false

d)

undefined

72.

Fill in the blank: To assign the string to a variable called person in Javascript, you write: var person = ________;

a)

"John Doe"

b)

John Doe

c)

'John Doe'

d)

person

73.

Fill in the blank: The escape character \ in Javascript represents a ________ quote.

a)

single

b)

double

c)

backtick

d)

triple

74.

The escape character " in Javascript represents a ________ quote.

a)

double

b)

single

c)

backtick

d)

triple

75.

Fill in the blank: The escape character \ in Javascript represents a ________.

a)

backslash

b)

forward slash

c)

colon

d)

semicolon

76.

Fill in the blank: The escape character \b in Javascript represents a ________.

a)

backspace

b)

bell

c)

tab

d)

newline

77.

Fill in the blank: The escape character \f in Javascript represents a ________ feed.

a)

form

b)

line

c)

page

d)

data

78.

Fill in the blank: The escape character \n in Javascript represents a ________ line.

a)

new

b)

old

c)

blank

d)

single

79.

Fill in the blank: The escape character \r in Javascript represents a ________ return.

a)

carriage

b)

line

c)

page

d)

form

80.

Fill in the blank: The escape character \t in Javascript represents a ________ tabulator.

a)

horizontal

b)

vertical

c)

diagonal

d)

reverse

81.

Which JavaScript string method returns a character at a specified position inside a string?

a)

charAt()

b)

substring()

c)

split()

d)

concat()

82.

Which JavaScript string method gives you the unicode of character at that position?

a)

charCodeAt()

b)

indexOf()

c)

slice()

d)

concat()

83.

Which JavaScript string method concatenates (joins) two or more strings into one?

a)

concat()

b)

split()

c)

slice()

d)

replace()

84.

Which JavaScript string method returns a string created from the specified sequence of UTF-16 code units?

a)

fromCharCode()

b)

charAt()

c)

concat()

d)

slice()

85.

Which JavaScript string method provides the position of the first occurrence of a specified text within a string?

a)

indexOf()

b)

substring()

c)

split()

d)

replace()

86.

Which JavaScript string method is the same as indexOf() but with the last occurrence, searching backwards?

a)

lastIndexOf()

b)

search()

c)

substring()

d)

split()

87.

Which JavaScript string method retrieves the matches of a string against a search pattern?

a)

match()

b)

search()

c)

replace()

d)

split()

88.

Which JavaScript string method finds and replaces specific text in a string?

a)

replace()

b)

split()

c)

concat()

d)

slice()

89.

Which JavaScript string method executes a search for a matching text and returns its position?

a)

search()

b)

replace()

c)

split()

d)

concat()

90.

Which JavaScript string method extracts a section of a string and returns it as a new string?

a)

slice()

b)

split()

c)

replace()

d)

concat()

91.

Which JavaScript string method splits a string object into an array of strings at a specified position?

a)

split()

b)

slice()

c)

join()

d)

replace()

92.

Which JavaScript string method is similar to slice() but extracts a substring depended on a specified number of characters?

a)

substr()

b)

substring()

c)

split()

d)

concat()

93.

Which JavaScript string method is also similar to slice() but can’t accept negative indices?

a)

substring()

b)

substr()

c)

split()

d)

replace()

94.

Which JavaScript string method converts a string to lowercase?

a)

toLowerCase()

b)

toUpperCase()

c)

toLower()

d)

convertLowerCase()

95.

What does the JavaScript method toUpperCase() do?

a)

Converts strings to uppercase

b)

Converts strings to lowercase

c)

Removes spaces from strings

d)

Reverses the string

96.

What does the JavaScript method valueOf() return?

a)

Returns the primitive value (that has no properties or methods) of a string object

b)

Returns the length of the string object

c)

Returns the string object in uppercase

d)

Returns the type of the string object

97.

What does the JavaScript method toLowerCase() do?

a)

Converts strings to lowercase

b)

Converts strings to uppercase

c)

Removes all spaces from a string

d)

Returns the length of a string