Grade 8 ch9
Grade 8 ch9
Introduction to Javascript
1. Define JavaScript.
JavaScript is a high-level, interpreted programming language that is primarily known for its use
in web browsers to make web pages interactive. It enables dynamic content, client-side scripting,
and the creation of user interfaces.
2. Define a variable.
A variable in JavaScript is a named storage location that holds data values. It is defined using the
var, let, or const keyword, followed by the variable name.
confirm() box: Displays a dialog box with OK and Cancel buttons. Returns true if OK is pressed
and false if Cancel is pressed.
prompt() box: Displays a dialog box with an input field and OK/Cancel buttons. Returns the
input value if OK is pressed and null if Cancel is pressed.
document.write(): Writes content without adding a new line. It replaces the entire content if used
after the document has been fully loaded.
document.writeln(): Writes content and adds a new line after each call.
JavaScript dialogue boxes include alert b0oxes (for short messages), confirm boxes (for user
decisions), and prompt boxes (for accepting user input). They are non-blocking, synchronous,
and their appearance is controlled by the browser.
Long answer
1. Write a few points one should keep in mind while naming a variable.
Answer
a. Interactivity: Enables interaction with users on web pages.
b. Client-Side Scripting: Executed on the client's browser.
c. Object-Oriented: Supports object-oriented programming.
d. Asynchronous Execution: Supports asynchronous operations with callbacks and promises.
e. Dynamic Typing: Variables are not explicitly typed.
f. Event-Driven Programming: Responds to events triggered by user actions or the browser.