ITI COPA (Computer Operator & Programming Assistant) – Basic Notes
Topic- Introduction to JavaScript
1. Programming and Scripting Languages
A programming language is used to develop software applications, operating systems, and complex programs. Examples include C, C++, Java.
A scripting language is mainly used to control applications and automate tasks. Scripts are executed line by line without compilation.
Examples of Scripting Languages
-
JavaScript
-
Python
-
PHP
-
Shell Script
Difference
| Programming Language | Scripting Language |
|---|---|
| Compiled | Interpreted |
| Used for software | Used for automation |
| Example: C, Java | Example: JavaScript |
2. Introduction to JavaScript and Its Web Applications
JavaScript is a client-side scripting language used to create interactive web pages.
Uses of JavaScript
-
Form validation
-
Popup messages
-
Image sliders
-
Menu effects
-
Dynamic content update
-
Animation and multimedia
JavaScript runs inside the web browser and works with HTML and CSS.
3. Introduction to Web Servers and Their Features
A web server stores website files and delivers them to users using HTTP or HTTPS.
Examples of Web Servers
-
Apache
-
Nginx
-
IIS
Features
-
Handles multiple requests
-
Provides security
-
Supports scripting languages
-
Works 24×7
4. JavaScript Basics
4.1 Data Types
-
Number
-
String
-
Boolean
-
Undefined
-
Null
4.2 Variables
Variables store values.
Keywords:
-
var -
let -
const
4.3 Constants
Constants store fixed values.
4.4 Type Conversion
-
Number() -
String() -
Boolean() -
parseInt() -
parseFloat()
5. Operators in JavaScript
Arithmetic Operators
+ - * / %
Comparison Operators
== === != > < >= <=
Logical Operators
&& || !
Operator Precedence
-
Brackets
-
Arithmetic
-
Comparison
-
Logical
6. Control Statements and Loops
Conditional Statements
-
if -
if-else -
else-if -
switch
Loops
-
for -
while -
do-while -
for...in -
for...of
7. Arrays in JavaScript
An array stores multiple values in one variable.
Types
-
Numeric array
-
String array
-
Mixed array
-
Multidimensional array
Array Properties
-
length -
Index starts from 0
8. String Data Type
Strings are text values enclosed in quotes.
String Functions
-
length -
toUpperCase() -
toLowerCase() -
indexOf() -
replace() -
substring()
9. Math and Date Objects
Math Object
-
Math.sqrt() -
Math.pow() -
Math.random() -
Math.round()
Date Object
-
getDate() -
getMonth() -
getFullYear() -
getTime()
10. Functions in JavaScript
A function is a reusable block of code.
Types
-
User-defined
-
Built-in
-
Anonymous
-
Arrow functions
Advantages
-
Code reuse
-
Easy maintenance
-
Reduces repetition
11. Built-in JavaScript Functions
-
alert() -
confirm() -
prompt() -
parseInt() -
parseFloat() -
isNaN()
12. Pop-up Boxes
Types
-
Alert box – message display
-
Confirm box – Yes/No
-
Prompt box – input from user
13. Document Object Model (DOM)
DOM represents an HTML page as a tree structure.
Uses of DOM
-
Access HTML elements
-
Change content
-
Modify CSS
-
Handle events
14. Animation and Multimedia in JavaScript
JavaScript can:
-
Animate text and images
-
Control audio and video
-
Create interactive effects
Used in:
-
Websites
-
Games
-
Educational apps
MCQ Questions (30 – CBT Exam)
1. JavaScript is a:
A) Programming language
B) Scripting language
C) Markup language
D) Query language
Ans: B
2. JavaScript is mainly used for:
A) Database design
B) Styling pages
C) Making web pages interactive
D) Hardware control
Ans: C
3. JavaScript runs on:
A) Server
B) Browser
C) CPU
D) RAM
Ans: B
4. Which keyword is used to declare a constant?
A) var
B) let
C) const
D) static
Ans: C
5. Which is NOT a JavaScript data type?
A) Number
B) String
C) Boolean
D) Character
Ans: D
6. === operator checks:
A) Value only
B) Type only
C) Value and type
D) Assignment
Ans: C
7. Which operator is used for AND?
A) &
B) &&
C) ||
D) !
Ans: B
8. Which loop executes at least once?
A) for
B) while
C) do-while
D) for-in
Ans: C
9. Array index starts from:
A) 1
B) 0
C) -1
D) Any number
Ans: B
10. Which function displays a message box?
A) prompt()
B) confirm()
C) alert()
D) message()
Ans: C
11. Which function takes user input?
A) alert()
B) prompt()
C) confirm()
D) input()
Ans: B
12. Which object is used for math operations?
A) Number
B) Math
C) Calc
D) Integer
Ans: B
13. Which object handles date and time?
A) Time
B) Clock
C) Date
D) Day
Ans: C
14. JavaScript functions are used for:
A) Repetition
B) Storage
C) Reusability
D) Security
Ans: C
15. DOM stands for:
A) Document Object Model
B) Data Object Model
C) Digital Object Method
D) Document Oriented Model
Ans: A
16. DOM allows JavaScript to:
A) Access HTML elements
B) Compile code
C) Store data
D) Create database
Ans: A
17. Which loop is used to repeat code?
A) if
B) switch
C) loop
D) for
Ans: D
18. JavaScript is a:
A) Case-insensitive language
B) Case-sensitive language
C) Machine language
D) Assembly language
Ans: B
19. Which operator is used for OR?
A) &&
B) ||
C) !
D) ==
Ans: B
20. Which is a built-in JavaScript function?
A) print()
B) alert()
C) show()
D) input()
Ans: B
21. Which keyword declares a variable with block scope?
A) var
B) let
C) static
D) define
Ans: B
22. Which object is used for animation?
A) CSS only
B) JavaScript
C) HTML only
D) Database
Ans: B
23. JavaScript is mainly used on:
A) Server-side only
B) Client-side
C) Hardware
D) OS kernel
Ans: B
24. Which operator has highest precedence?
A) Logical
B) Comparison
C) Arithmetic
D) Assignment
Ans: C
25. JavaScript arrays can store:
A) One value
B) Multiple values
C) Only numbers
D) Only strings
Ans: B
26. Which function converts string to integer?
A) Number()
B) parseInt()
C) parseFloat()
D) String()
Ans: B
27. Which symbol is used for comments?
A) <!-- -->
B) //
C) **
D) ##
Ans: B
28. Multimedia in JavaScript includes:
A) Text only
B) Audio and video
C) Database
D) Compiler
Ans: B
29. JavaScript improves:
A) Page security only
B) Interactivity
C) Hardware speed
D) Storage
Ans: B
30. JavaScript is used with:
A) HTML only
B) CSS only
C) HTML and CSS
D) Database
Ans: C
No comments:
Post a Comment
Give your valuable feedback