JavaScript Basics Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By ProProfs AI
P
ProProfs AI
Community Contributor
Quizzes Created: 81 | Total Attempts: 817
| Questions: 15 | Updated: May 1, 2026
Please wait...
Question 1 / 16
🏆 Rank #--
0 %
0/100
Score 0/100

1. What will the following code output? console.log(typeof 'hello');

Explanation

The code uses the `typeof` operator, which returns a string indicating the type of the unevaluated operand. In this case, the operand is the string 'hello'. Since 'hello' is indeed a string, the output will be 'string', confirming its data type in JavaScript.

Submit
Please wait...
About This Quiz
JavaScript Basics Quiz - Quiz

Test your understanding of JavaScript Basics Quiz fundamentals with this medium-difficulty assessment. Covering variables, data types, operators, functions, and DOM manipulation, this quiz helps Grade 10 students solidify core JavaScript concepts essential for web development. Perfect for reinforcing classroom learning and identifying areas for improvement.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which keyword declares a variable that cannot be reassigned?

Explanation

The `const` keyword is used in JavaScript to declare variables that are block-scoped and cannot be reassigned after their initial value is set. This ensures that the variable remains constant throughout its scope, providing a safeguard against accidental changes to its value.

Submit

3. What is the result of 5 + '5' in JavaScript?

Explanation

In JavaScript, when a number is added to a string, the number is converted to a string, and the two strings are concatenated. In this case, the number 5 is converted to '5', resulting in the concatenation of '5' and '5', which produces '55'.

Submit

4. Which method adds an element to the end of an array?

Explanation

The `push()` method is specifically designed to add one or more elements to the end of an array in programming languages like JavaScript. It modifies the original array by increasing its length and placing the new element(s) at the last position, making it a commonly used method for array manipulation.

Submit

5. What does DOM stand for?

Explanation

DOM stands for Document Object Model, which is a programming interface for web documents. It represents the structure of a document as a tree of objects, allowing developers to manipulate the content, structure, and style of web pages dynamically using languages like JavaScript. This makes it essential for interactive web development.

Submit

6. How do you create a function in JavaScript?

Explanation

In JavaScript, functions are defined using the keyword `function`, followed by the function name, parentheses for parameters, and curly braces to enclose the function body. This syntax allows you to create reusable code blocks that can be executed when called. The other options use incorrect syntax from other programming languages.

Submit

7. What is the correct syntax for an if statement?

Explanation

The correct syntax for an if statement in many programming languages requires the condition to be enclosed in parentheses. This format ensures clarity and proper evaluation of the condition. The curly braces denote the block of code that will execute if the condition is true, adhering to standard conventions in languages like C, C++, and Java.

Submit

8. Which operator is used for logical AND?

Explanation

The logical AND operator in many programming languages, such as C, C++, and Java, is represented by "&&". It evaluates to true only if both operands are true. This operator is essential for combining multiple conditions in conditional statements, ensuring that all specified conditions must be satisfied for the overall expression to be true.

Submit

9. What does the return keyword do in a function?

Explanation

The return keyword in a function terminates its execution and provides a specified value back to the caller. This allows the function to output results that can be used elsewhere in the program, enabling effective data handling and manipulation. It essentially marks the end of the function's process and delivers the result.

Submit

10. How do you select an HTML element by its ID in JavaScript?

Explanation

In JavaScript, to select an HTML element by its ID, you use the method `document.getElementById('id')`. This method retrieves the first element with the specified ID, allowing you to manipulate or access its properties directly. The other options provided are incorrect syntax or do not exist in the JavaScript DOM API.

Submit

11. What is the index of the first element in an array?

Explanation

In most programming languages, array indexing starts at 0. This means the first element of an array is accessed using the index 0, making it the position of the first element. Thus, the index of the first element in an array is 0.

Submit

12. Which loop repeats code while a condition is true?

Explanation

A while loop is designed to execute a block of code repeatedly as long as a specified condition remains true. This allows for dynamic repetition based on changing conditions, making it useful for situations where the number of iterations isn't predetermined. In contrast, for loops and if statements serve different purposes.

Submit

13. What is a callback function?

Submit

14. How do you add a comment in JavaScript?

Submit

15. What does JSON stand for?

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What will the following code output? console.log(typeof 'hello');
Which keyword declares a variable that cannot be reassigned?
What is the result of 5 + '5' in JavaScript?
Which method adds an element to the end of an array?
What does DOM stand for?
How do you create a function in JavaScript?
What is the correct syntax for an if statement?
Which operator is used for logical AND?
What does the return keyword do in a function?
How do you select an HTML element by its ID in JavaScript?
What is the index of the first element in an array?
Which loop repeats code while a condition is true?
What is a callback function?
How do you add a comment in JavaScript?
What does JSON stand for?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!