MCQs on Introduction to JavaScript | JavaScript

JavaScript is a versatile, powerful scripting language used widely in web development. This chapter introduces JavaScript’s origins, setup steps, and foundational code practices to get you started coding directly in HTML.


Chapter 1: Introduction to JavaScript


Topic 1: History and Evolution of JavaScript

  1. Which company developed JavaScript in 1995?
    • a) Microsoft
    • b) Netscape
    • c) Apple
    • d) Google
  2. JavaScript was initially known as:
    • a) Mocha
    • b) Java
    • c) TypeScript
    • d) ECMAScript
  3. What was the main purpose of creating JavaScript initially?
    • a) Building server applications
    • b) Adding interactivity to web pages
    • c) Managing databases
    • d) Machine learning
  4. Who is considered the creator of JavaScript?
    • a) Tim Berners-Lee
    • b) Brendan Eich
    • c) Dennis Ritchie
    • d) Larry Page
  5. In which year was ECMAScript 6, a major JavaScript update, released?
    • a) 2009
    • b) 2011
    • c) 2015
    • d) 2018
  6. Which organization is responsible for the standardization of JavaScript?
    • a) ISO
    • b) ECMA
    • c) IEEE
    • d) W3C

Topic 2: Setting Up the Environment (Editors, Browsers)

  1. Which of the following is NOT a commonly used code editor for JavaScript?
    • a) Visual Studio Code
    • b) Eclipse
    • c) MS Word
    • d) Atom
  2. Which browser is NOT recommended for testing JavaScript?
    • a) Chrome
    • b) Firefox
    • c) Safari
    • d) Internet Explorer 6
  3. To run JavaScript code, you need:
    • a) A text editor and a web browser
    • b) Only a text editor
    • c) Only a compiler
    • d) Special hardware
  4. Which of the following tools is mainly used to debug JavaScript in modern browsers?
    • a) Developer Console
    • b) FTP
    • c) Task Manager
    • d) Windows PowerShell
  5. Node.js is primarily used for:
    • a) Front-end development
    • b) Back-end development
    • c) Design work
    • d) File management
  6. Which of these environments supports JavaScript?
    • a) Web browsers
    • b) Operating systems
    • c) Mobile phones only
    • d) Only on web servers

Topic 3: Writing and Running Your First JavaScript Code

  1. JavaScript code can be written inside a file with which extension?
    • a) .java
    • b) .js
    • c) .jsx
    • d) .css
  2. To display an alert box with a message, which command is used?
    • a) display(“Hello World”)
    • b) alert(“Hello World”)
    • c) console.log(“Hello World”)
    • d) popup(“Hello World”)
  3. Which of these is correct syntax to print “Hello, World!” in the console?
    • a) print(“Hello, World!”)
    • b) alert(“Hello, World!”)
    • c) console.log(“Hello, World!”)
    • d) show(“Hello, World!”)
  4. In which HTML tag can you write JavaScript code?
    • a) <html>
    • b) <body>
    • c) <script>
    • d) <link>
  5. Which of the following is a valid way to add comments in JavaScript?
    • a) ## This is a comment
    • b) // This is a comment
    • c) <!-- This is a comment -->
    • d) * This is a comment
  6. To create a variable in JavaScript, you can use which keyword?
    • a) int
    • b) let
    • c) define
    • d) const

Topic 4: JavaScript in HTML: <script> Tag and Inline Script

  1. The <script> tag is typically placed in:
    • a) <header>
    • b) <footer>
    • c) <head> or <body>
    • d) <title>
  2. An inline JavaScript code is written:
    • a) In an external .js file
    • b) Inside the HTML page directly
    • c) In a CSS file
    • d) In the server code
  3. How do you link an external JavaScript file in HTML?
    • a) <script src="file.js">
    • b) <link src="file.js">
    • c) <style src="file.js">
    • d) <js src="file.js">
  4. Which attribute must be included in the <script> tag for external files?
    • a) href
    • b) src
    • c) style
    • d) link
  5. Inline scripts are written:
    • a) In the <script> tag with no src attribute
    • b) In the <script> tag with src attribute
    • c) In an external JavaScript file
    • d) None of the above
  6. What attribute allows JavaScript to load asynchronously in HTML?
    • a) sync
    • b) async
    • c) defer
    • d) load
  7. What is the purpose of the defer attribute in the <script> tag?
    • a) Loads script at the beginning of the page
    • b) Loads script before HTML parsing
    • c) Defers script loading until HTML is parsed
    • d) Prevents script from loading
  8. Which code correctly embeds JavaScript directly into HTML?
    • a) <style>JavaScript code</style>
    • b) <script>JavaScript code</script>
    • c) <html>JavaScript code</html>
    • d) <code>JavaScript code</code>
  9. An advantage of using external JavaScript files is:
    • a) Faster execution
    • b) Better security
    • c) Cleaner code structure
    • d) Higher browser compatibility
  10. The <script> tag’s type attribute is often set to:
    • a) “text/css”
    • b) “application/xml”
    • c) “text/javascript”
    • d) “application/json”
  11. What will the following code output in the browser console: console.log(5 + "5");?
    • a) 10
    • b) 55
    • c) Error
    • d) Undefined
  12. Which of the following is NOT a correct way to include JavaScript in HTML?
    • a) External script
    • b) Inline script
    • c) Internal CSS
    • d) Internal script

Answer Key

QnoAnswer
1b) Netscape
2a) Mocha
3b) Adding interactivity
4b) Brendan Eich
5c) 2015
6b) ECMA
7c) MS Word
8d) Internet Explorer 6
9a) A text editor and a web browser
10a) Developer Console
11b) Back-end development
12a) Web browsers
13b) .js
14b) alert(“Hello World”)
15c) console.log(“Hello, World!”)
16c) <script>
17b) // This is a comment
18b) let
19c) <head> or <body>
20b) Inside the HTML page directly
21a) <script src="file.js">
22b) src
23a) In the <script> tag with no src attribute
24b) async
25c) Defers script loading until HTML is parsed
26b) <script>JavaScript code</script>
27c) Cleaner code structure
28c) “text/javascript”
29b) 55
30c) Internal CSS

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top