JavaScript Basics - Q&A
Q1: What is an editor?
An editor is a software used to write and edit code, such as Notepad, VS Code, or Sublime Text.
Q2: What do you understand by a web browser?
A web browser is an application used to access and view websites. It interprets HTML, CSS, and JavaScript.
Q3: What are the major types of browsers available today?
Google Chrome, Mozilla Firefox, Microsoft Edge, Apple Safari, and Opera.
Q4: What is the advantage of using JavaScript over HTML?
JavaScript allows interactivity and dynamic behavior on web pages, unlike HTML which is static.
Q5: What are the steps needed to create and run a simple program using JavaScript?
1. Open a text editor.
2. Write HTML and JavaScript code.
3. Save the file with .html extension.
4. Open in browser.
Q6: Which attribute of the <script> tag helps you include an external JavaScript file?
The 'src' attribute is used to include external JavaScript files.
Q7: What are the three ways in which JavaScript can be included?
1. Inline
2. Internal (within <script>)
3. External (using src attribute).
Q8: JavaScript is interpreted - what does this imply?
It means JavaScript code is executed line-by-line by the browser without prior compilation.
Q9: Explain the role of case sensitivity in JavaScript.
JavaScript is case-sensitive. For example, 'Document', 'document', and 'DOCUMENT' are all different.
Q10: How to use multiple line comments in JavaScript?
Use /* comment */ for multiline comments.
Q11: Fill in the blanks
(a) A file which ends with .js is an _external JavaScript file_.
(b) JS programs are included within _<script>_ & _</script>_ of an HTML document.
(c) Generally HTML is preferred for creating _structure_, CSS for _styling_, and JavaScript for _interactivity_.
(d) JavaScript syntax is a set of _rules_ that define a structured JavaScript.
(e) Comments are used to _explain or disable code_ in JavaScript programs.