W3Tutorials.net
Toggle Menu
Home
Online Go Compiler
Tutorials
Javascript Tutorials
Python Tutorials
Go Tutorials
Blog
All Posts
JavaScript Basics for Beginners
Test your understanding of variables,functions,and loops in JS.
1. Which keyword is used to declare a block-scoped variable in JavaScript?
var
let
const
function
2. Which of the following are primitive data types in JavaScript? (Select all that apply)
String
Number
Boolean
Object
Null
Array
3. JavaScript is a statically typed programming language.
True
False
4. What is the output of console.log(2 + '2')?
5. What is the result of the expression: 5 > 3 && 2 > 7?
true
false
undefined
NaN
6. Which array method adds an element to the end of an array?
push()
pop()
shift()
unshift()
7. What does the acronym 'NaN' stand for in JavaScript?
Not a Number
Null and Number
New Array Notation
None of the above
8. Which loop is used to iterate over the properties of an object?
for
for...in
for...of
while
9. What is the output of typeof null?
null
object
undefined
number
10. Which function converts a string to an integer?
parseInt()
parseFloat()
toInt()
stringToInt()
11. Which of the following are valid JavaScript variable names? (Select all that apply)
myVar
1var
var-1
_var
$var
12. Which array methods modify the original array? (Select all that apply)
push()
slice()
splice()
map()
reverse()
13. Which of the following are comparison operators in JavaScript? (Select all that apply)
==
===
=
!=
!==
14. Which of the following are ways to create a function in JavaScript? (Select all that apply)
Function declaration
Function expression
Arrow function
Object constructor
Class constructor
15. The 'this' keyword in a global function refers to the window object in web browsers.
True
False
16. An empty array ([]) is considered falsy in JavaScript.
True
False
17. JavaScript code always executes line by line from top to bottom without exceptions.
True
False
18. What keyword is used to exit a loop early?
19. What is the output of console.log(typeof 'Hello World')?
20. What does the acronym JSON stand for?
Reset
Answered 0 of 0 — 0 correct