CLASS 8 INTRODUCTION TO JAVASCRIPT

 INTRODUCTION TO JAVASCRIPT


A. Tick the correct option

  1. Which dialogue box prompts the user to enter value?

    • Answer: d. Prompt box

  2. Which of the following is the extension for an external JavaScript file?

    • Answer: c. .js

  3. Which of the following statement is not true about JavaScript?

    • Answer: a. It is not a case-sensitive language. (JavaScript is case-sensitive)

  4. What is the other name for an object in JavaScript?

    • Answer: b. Key

  5. Which of the following is not true about variable name?

    • Answer: a. It can contain space. (Variable names cannot contain spaces)

B. Fill in the blanks

  1. Alert box displays a short message in a separate window.

  2. Variable is the memory location that stores values.

  3. document.writeln() object method displays the output with a line break.

  4. The src attribute is used with external JavaScript.

  5. The values of constants remain fixed.

C. State True or False

  1. JavaScript cannot be used with HTML tags. — False

  2. Looping means to repeat the statements multiple times till the condition is true. — True

  3. By default, a variable in JavaScript is declared as global. — True

  4. <script> tag cannot be placed inside the <head> tag. — False

  5. JavaScript is not an object-oriented language. — False(It is an object-based / prototype-based object-oriented language)

D. Match the following:-
1. Function                 b. Allows you to define your own functions in JavaScript.
2. var                           d. Value that keeps on changing in a program.
3. SRC                         e. Used in external JavaScript.
4. <SCRIPT>               a. Used to embed JavaScript in HTML.
5. document.write()   c. Displays the output after execution of the script.

E. Answer the following questions

1. Define JavaScript.

Answer: JavaScript is a dynamic, lightweight, client-side scripting language used to make web pages interactive and dynamic.

2. What is the usage of <SCRIPT> tag?

Answer: The <SCRIPT> tag (or <script>) is used in HTML documents to embed or reference executable JavaScript code.

3. Define a variable.

Answer: A variable is a named container or memory location used to store data values that can be referenced and modified during program execution.

4. Write another name for object in JavaScript.

Answer: An object in JavaScript is often referred to as a property container or a collection of key-value pairs (or an instance of a class/type).

5. Name two ways to embed JavaScript in HTML.

Answer:

  1. Internal JavaScript: Writing script code directly inside the <script> tag within the HTML file.

  2. External JavaScript: Linking an external file containing JavaScript code using the src attribute of the <script> tag (e.g., <script src="script.js"></script>).

6. Write the features of JavaScript language.

Answer:

  • Lightweight and Interpreted: Executed directly by the browser without needing pre-compilation.

  • Client-Side Processing: Runs on the user’s browser, reducing server load.

  • Dynamic Typing: Variables do not require strict type definitions.

  • Event-Driven: Can react to user actions like button clicks, mouse hovers, and key presses.

  • Platform Independent: Works across all major operating systems and modern web browsers.

7. What is the difference between document.write() and document.writeln()?

Answer:

  • document.write(): Outputs text directly to the HTML document on the same line.

  • document.writeln(): Outputs text to the HTML document and appends a new line character (\n) at the end of the content.

8. Write a few points one should keep in mind while naming a variable.

Answer:

  • Case Sensitivity: Variable names are case-sensitive (myVar and myvar are different).

  • Allowed Characters: Names can contain letters, digits, underscores (_), and dollar signs ($).

  • First Character: A variable name must start with a letter, an underscore (_), or a dollar sign ($), but cannot start with a number.

  • Reserved Words: Reserved keywords (like var, let, function, if) cannot be used as variable names.

9. Write the difference between confirm box and prompt box.

Answer:

  • confirm() Box: Displays a dialog box with a specified message along with OK and Cancel buttons. It returns true if OK is clicked and false if Cancel is clicked.

  • prompt() Box: Displays a dialog box with a text input field along with OK and Cancel buttons. It allows the user to enter input and returns the entered text (or null if canceled).

10. Explain the external JavaScript with an example.

Answer: External JavaScript involves writing JavaScript code in a separate file saved with a .js extension, and then linking it to an HTML document using the src attribute inside the <script> tag. This improves code reusability and clean structure.


PROGRAM 01

PROGRAM 02

PROGRAM 03
PROGRAM 04

PROGRAM 05

<html>
<head>
<title> using variables </title>
</head>
<body>
<script language="JavaScript">
      var userName="Himani";
      var Age=12;
      document.write(userName);
      var Agel;
      Agel=Age;
      document.write(Agel);
</script>
</body>
</html>

https://aictacademy2026.blogspot.com/2026/10/php-vulnerability.html
vscode.dev

Comments

Popular posts from this blog

TYPES OF HARDWARE CLASS IX

Computer Applications Class IX Types of Software (Chap 3)

CLASS X SYLLABUS 2026-27