Learn with Yasir
Share Your Feedback

JavaScript Basics Quiz – True or False Questions for Beginners

Test your understanding of JavaScript fundamentals with this beginner-friendly true or false quiz. Learn key concepts like variables, functions, DOM manipulation, and script placement in a fun and simple format.

🔍 True or False

🟢 Beginner

  1. JavaScript can be used to change the content of an HTML element dynamically.
  2. Answer

    ✅ True – JavaScript can manipulate the DOM using methods like `document.getElementById().innerHTML`.


  3. The `alert()` function writes content directly into the HTML document.
  4. Answer

    ❌ False – `alert()` displays a popup message, it does not write content into the document.


  5. It is a best practice to place JavaScript code at the end of the body tag.
  6. Answer

    ✅ True – Placing scripts at the end of the body allows the HTML to load before the JavaScript executes.


  7. A JavaScript variable can hold different types of values at different times.
  8. Answer

    ✅ True – JavaScript is dynamically typed, which means a variable can be reassigned to different data types during execution.


  9. The `prompt()` function can be used to take input from the user.
  10. Answer

    ✅ True – `prompt()` opens a dialog box for the user to enter input.


  11. JavaScript functions cannot return values.
  12. Answer

    ❌ False – JavaScript functions can return values using the `return` statement.


  13. External JavaScript files are included in HTML using the `<link>` tag.
  14. Answer

    ❌ False – External scripts are included using the `<script src="..."></script>` tag.


🟡 Intermediate

  1. The `defer` attribute ensures scripts are executed after the HTML is parsed.
  2. Answer

    ✅ True – The `defer` attribute defers execution of the script until after the document has been parsed.


🔴 Advanced

📚 Related Resources


🧠 Practice & Progress

Explore More Topics