0% found this document useful (0 votes)
4 views4 pages

Javascript Notes

JavaScript is a lightweight, interpreted programming language primarily used for creating interactive web pages, featuring dynamic typing and event-driven capabilities. It offers advantages such as client-side execution and ease of learning, but also has disadvantages like security risks and browser compatibility issues. The document covers various aspects of JavaScript, including types of scripts, coding rules, output display methods, variables, operators, and control statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Javascript Notes

JavaScript is a lightweight, interpreted programming language primarily used for creating interactive web pages, featuring dynamic typing and event-driven capabilities. It offers advantages such as client-side execution and ease of learning, but also has disadvantages like security risks and browser compatibility issues. The document covers various aspects of JavaScript, including types of scripts, coding rules, output display methods, variables, operators, and control statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Full Notes

1. What is JavaScript?
JavaScript is a lightweight, interpreted programming language mainly used to make web
pages interactive. It runs on the client side (browser) and adds dynamic behavior like
animations, form validations, and pop-ups.

2. Features of JavaScript
- Lightweight and fast

- Interpreted language

- Dynamic typing

- Object-based

- Event-driven

- Cross-platform

- Easy to integrate with HTML/CSS

3. Advantages of JavaScript
- Runs on the client-side

- Reduces server load

- Adds interactivity to web pages

- Easy to learn

- Supported by all browsers

- Works well with HTML/CSS

4. Disadvantages of JavaScript
- Code is visible to users (security risk)

- Behavior may vary across browsers

- Can be disabled by users

- Limited file handling capability


- Not suitable for heavy backend tasks alone

5. What is a Script?
A script is a set of instructions written to perform a specific task. In web development, it
often refers to code written in a scripting language like JavaScript.

6. Types of Script
- Client-side Script: Runs in the browser (e.g., JavaScript)

- Server-side Script: Runs on the server (e.g., PHP, Python)

7. How JavaScript Works


1. Browser loads HTML page.

2. Finds JavaScript code inside <script> tags or linked .js files.

3. JavaScript engine interprets and executes the code.

4. Executes code and manipulates the web page as needed.

8. Ways to Execute JavaScript


a) Inline: <button onclick="alert('Hello!')">Click me</button>

b) Internal: <script>alert("Internal JS");</script>

c) External: <script src="script.js"></script>

9. JavaScript Coding Rules


- Use camelCase for variables

- End statements with a semicolon (;)

- Use comments: // single-line or /* multi-line */

- Avoid global variables

- Indent code properly

10. Ways to Display Output


- alert(): Popup box
- document.write(): Writes to page

- console.log(): Outputs to browser console

- innerHTML: Changes content of HTML elements

11. Variables in JavaScript


Variables are containers for data.

var x = 5;

let y = "Hello";

const PI = 3.14;

Types:

- var: Function-scoped

- let: Block-scoped

- const: Block-scoped, constant

12. Ways to Use JavaScript in Web Page


a) Inside <script> tag: <script>alert("JS");</script>

b) External file: <script src="main.js"></script>

13. Operators in JavaScript


Arithmetic: +, -, *, /, %, ++, --

Assignment: =, +=, -=, etc.

Comparison: ==, !=, ===, <, >, etc.

Logical: &&, ||, !

Bitwise: &, |, ^, ~, <<, >>, >>>

Special: typeof, instanceof, new, delete


14. Control Statements
if, if-else, else-if ladder, switch-case

Loops:

- for

- while

- do...while

- for...in (objects)

- for...of (arrays)

You might also like