WorksheetsTable of Contents - Beginner's Javascript Cheat Sheet
Total questions: 97
Worksheet time: 49mins
What is the purpose of 'Javascript Basics' in learning Javascript?
To introduce fundamental concepts and syntax of Javascript.
To teach advanced frameworks like React.
To cover server-side programming with Node.js.
To focus on mobile app development using Javascript.
What are 'Variables' used for in Javascript?
To store data values.
To create functions.
To display output on the screen.
To define loops.
What is an 'Array' in Javascript?
A data structure used to store multiple values in a single variable.
A function that returns a single value.
A type of loop used for iteration.
A keyword used to declare variables.
Which of the following best describes 'Operators' in Javascript?
Functions
Symbols that perform operations on variables and values
Loops
Statements
What is the main use of 'Functions' in Javascript?
To group reusable code into blocks that can be called when needed.
To store data permanently in the browser.
To style web pages using CSS.
To create database connections.
What is the purpose of 'Loops' in Javascript?
To execute a block of code repeatedly as long as a condition is true.
To declare variables in Javascript.
To create functions in Javascript.
To import external libraries in Javascript.
What do 'If - Else Statements' allow you to do in Javascript?
To make decisions in code based on conditions.
To create loops in code.
To declare variables.
To define functions.
What are 'Strings' in Javascript?
Sequences of characters used to represent text.
Numbers used for calculations.
Boolean values representing true or false.
Objects containing key-value pairs.
What are 'Regular Expressions' used for in Javascript?
To store numbers
To match patterns in strings
To create loops
To define functions
What is the role of 'Numbers and Math' in Javascript?
To perform mathematical operations and handle numeric data.
To manage string concatenation and text formatting.
To create and manipulate HTML elements.
To handle user authentication and session management.
What does 'Dealing with Dates' refer to in Javascript?
Working with date and time values using built-in objects and methods.
Handling string manipulation for user names.
Managing arrays and their elements.
Creating and styling HTML elements.
What is a 'DOM Node' in Javascript?
An object representing an element in the HTML document structure.
A variable used to store JavaScript functions.
A method for styling HTML elements.
A type of JavaScript loop.
What does 'Working with the Browser' mean in Javascript?
Interacting with browser features and APIs, such as manipulating the DOM or handling events.
Writing server-side code to manage databases.
Creating graphics using the Canvas API only.
Compiling JavaScript to machine code before execution.
What are 'Events' in Javascript?
Actions or occurrences that happen in the browser, which can be responded to using event handlers.
Variables that store user input in Javascript.
Functions that execute automatically when a page loads.
Objects used to style HTML elements.
What are 'Errors' in Javascript?
Problems that occur during code execution, which can be handled using error handling techniques.
Variables that store user input data.
Functions that execute automatically when a page loads.
Comments used to explain code logic.
Which HTML tag is used to include JavaScript code in a web page?
To call an external JavaScript file, use the following HTML tag:
myscript.js
script.js
external.js
file.js
Which symbol is used for single line comments in JavaScript?
//
/*
#
Which symbol is used for multi-line comments in JavaScript?
//
/* ... */
# ... #
Fill in the blank: The following code declares a variable with a number value: var age = ____
23
"23"
twenty-three
null
What is the value assigned to the variable 'a' in the following code? var a = "init"
init
start
undefined
null
What is the result of the following operation? var b = 1 + 2 + 3
6
5
7
9
What is the value of the variable 'c' in the following code? var c = true
true
false
null
undefined
What is the value of the constant PI in the following code? const PI = 3.14
3.14
2.71
1.62
3.00
What is the value of the 'firstName' property in the following object? var name = {firstName:"John", lastName:"Doe"}
John
Jane
Michael
David
Which of the following is the correct way to define an object in Javascript?
var person = {firstName:"John", lastName:"Doe", age:20, nationality:"German"};
var person = [firstName:"John", lastName:"Doe", age:20, nationality:"German"];
var person = "firstName:John, lastName:Doe, age:20, nationality:German";
What is the value of the second element in the following array? var fruit = ["Banana", "Apple", "Pear"];
Apple
Banana
Pear
Orange
Which array method would you use to join several arrays into one?
concat()
join()
indexOf()
lastIndexOf()
Which array method returns the first position at which a given element appears in an array?
concat()
join()
indexOf()
lastIndexOf()
Which array method combines elements of an array into a single string and returns the string?
concat()
join()
indexOf()
lastIndexOf()
Which array method gives the last position at which a given element appears in an array?
concat()
join()
indexOf()
lastIndexOf()
What does the '==' operator mean in Javascript?
Not equal
Equal to
Greater than
Less than
Fill in the blank: The '===' operator in Javascript means _______.
Equal value and equal type
Equal value only
Equal type only
Assignment operator
What does the '!=' operator mean in Javascript?
Not equal
Equal to
Less than
Greater than
Fill in the blank: The '!==' operator in Javascript means _______.
Not equal value or not equal type
Equal value and equal type
Not equal value but equal type
Equal value or not equal type
What does the '>' operator mean in Javascript?
Less than
Greater than
Equal to
Not equal
What does the '<' operator mean in Javascript?
Less than
Greater than
Equal to
Not equal
Fill in the blank: The '>=' operator in Javascript means _______.
Greater than or equal to
Less than or equal to
Equal to
Not equal to
Fill in the blank: The '<=' operator in Javascript means _______.
Less than or equal to
Greater than or equal to
Equal to
Not equal to
What does the '?' operator mean in Javascript?
Logical and
Ternary operator
OR statement
NOT
Fill in the blank: The '&&' operator in Javascript means _______.
Logical and
Bitwise and
Logical or
Assignment
Fill in the blank: The '||' operator in Javascript means _______.
Logical or
Logical and
Bitwise or
Assignment
Fill in the blank: The '!' operator in Javascript means _______.
Logical not
Logical and
Bitwise OR
Increment
What does the '&' operator mean in Javascript?
A) AND statement
B) OR statement
C) NOT
D) XOR
What does the '|' operator mean in Javascript?
AND statement
OR statement
NOT
XOR
Fill in the blank: The '~' operator in Javascript means _______.
NOT
AND
OR
XOR
Fill in the blank: The '^' operator in Javascript means _______.
XOR
Exponentiation
AND
OR
Fill in the blank: The '<<' operator in Javascript means _______.
Left shift
Right shift
Bitwise AND
Bitwise OR
Fill in the blank: The '>>' operator in Javascript means _______.
Right shift
Left shift
Bitwise AND
Bitwise OR
Fill in the blank: The '>>>' operator in Javascript means _______.
Zero fill right shift
Bitwise AND
Left shift
Bitwise OR
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 function
A variable
An array
A loop
What does alert() do in Javascript?
Writes information to the browser console
Opens a yes/no dialog
Outputs data in an alert box
Defines a function
What does confirm() do in Javascript?
Outputs data in an alert box
Opens a yes/no dialog and returns true/false depending on user click
Writes information to the browser console
Defines a function
What does console.log() do in Javascript?
Outputs data in an alert box
Opens a yes/no dialog
Writes information to the browser console
Defines a function
Which JavaScript function writes directly to the HTML document?
document.write()
console.log()
alert()
window.open()
Which JavaScript function creates a dialogue for user input?
prompt()
alert()
console.log()
confirm()
Which JavaScript global function decodes a Uniform Resource Identifier (URI) created by encodeURI or similar?
decodeURI()
decodeURIComponent()
parseURI()
unescapeURI()
Which JavaScript global function decodes a URI component?
decodeURIComponent()
encodeURIComponent()
decodeURI()
parseURI()
Which JavaScript global function encodes a URI into UTF-8?
encodeURI()
decodeURI()
escape()
parseInt()
Which JavaScript global function encodes a URI component into UTF-8?
encodeURIComponent()
decodeURIComponent()
escape()
encodeURI()
Which JavaScript global function evaluates JavaScript code represented as a string?
eval()
parseInt()
decodeURI()
JSON.stringify()
Which JavaScript global function determines whether a passed value is a finite number?
isFinite()
isNumber()
isInteger()
isFloat()
Which JavaScript global function determines whether a value is NaN or not?
isNaN()
parseInt()
isFinite()
Number()
Which JavaScript global function returns a number converted from its argument?
Number()
String()
parseInt()
Boolean()
Which JavaScript global function parses an argument and returns a floating point number?
parseFloat()
parseInt()
Number()
toFixed()
Which JavaScript global function parses its argument and returns an integer?
parseInt()
parseFloat()
Number()
toString()
What is the most common way to create a loop in Javascript?
while
for
do while
break
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?
for
while
do while
continue
Fill in the blank: The 'break' statement in Javascript is used to ________ and exit the cycle at certain conditions.
stop
continue
repeat
skip
Fill in the blank: The 'continue' statement in Javascript is used to ________ parts of the cycle if certain conditions are met.
skip
repeat
end
execute
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 ________ }
not met
true
false
undefined
Fill in the blank: To assign the string to a variable called person in Javascript, you write: var person = ________;
"John Doe"
John Doe
'John Doe'
person
Fill in the blank: The escape character \ in Javascript represents a ________ quote.
single
double
backtick
triple
The escape character " in Javascript represents a ________ quote.
double
single
backtick
triple
Fill in the blank: The escape character \ in Javascript represents a ________.
backslash
forward slash
colon
semicolon
Fill in the blank: The escape character \b in Javascript represents a ________.
backspace
bell
tab
newline
Fill in the blank: The escape character \f in Javascript represents a ________ feed.
form
line
page
data
Fill in the blank: The escape character \n in Javascript represents a ________ line.
new
old
blank
single
Fill in the blank: The escape character \r in Javascript represents a ________ return.
carriage
line
page
form
Fill in the blank: The escape character \t in Javascript represents a ________ tabulator.
horizontal
vertical
diagonal
reverse
Which JavaScript string method returns a character at a specified position inside a string?
charAt()
substring()
split()
concat()
Which JavaScript string method gives you the unicode of character at that position?
charCodeAt()
indexOf()
slice()
concat()
Which JavaScript string method concatenates (joins) two or more strings into one?
concat()
split()
slice()
replace()
Which JavaScript string method returns a string created from the specified sequence of UTF-16 code units?
fromCharCode()
charAt()
concat()
slice()
Which JavaScript string method provides the position of the first occurrence of a specified text within a string?
indexOf()
substring()
split()
replace()
Which JavaScript string method is the same as indexOf() but with the last occurrence, searching backwards?
lastIndexOf()
search()
substring()
split()
Which JavaScript string method retrieves the matches of a string against a search pattern?
match()
search()
replace()
split()
Which JavaScript string method finds and replaces specific text in a string?
replace()
split()
concat()
slice()
Which JavaScript string method executes a search for a matching text and returns its position?
search()
replace()
split()
concat()
Which JavaScript string method extracts a section of a string and returns it as a new string?
slice()
split()
replace()
concat()
Which JavaScript string method splits a string object into an array of strings at a specified position?
split()
slice()
join()
replace()
Which JavaScript string method is similar to slice() but extracts a substring depended on a specified number of characters?
substr()
substring()
split()
concat()
Which JavaScript string method is also similar to slice() but can’t accept negative indices?
substring()
substr()
split()
replace()
Which JavaScript string method converts a string to lowercase?
toLowerCase()
toUpperCase()
toLower()
convertLowerCase()
What does the JavaScript method toUpperCase() do?
Converts strings to uppercase
Converts strings to lowercase
Removes spaces from strings
Reverses the string
What does the JavaScript method valueOf() return?
Returns the primitive value (that has no properties or methods) of a string object
Returns the length of the string object
Returns the string object in uppercase
Returns the type of the string object
What does the JavaScript method toLowerCase() do?
Converts strings to lowercase
Converts strings to uppercase
Removes all spaces from a string
Returns the length of a string
