0% found this document useful (0 votes)
16 views1 page

JavaScript Basics: Variables, Functions, Operators

Uploaded by

shetyeom45
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)
16 views1 page

JavaScript Basics: Variables, Functions, Operators

Uploaded by

shetyeom45
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

1.

Core Concepts

• Client-Side Scripting: JavaScript runs on the user's browser, making pages dynamic without
server interaction.

• Scripts: A script is a list of commands executed to make web pages interactive.

• Embedding JavaScript in HTML: Add JavaScript inside ... tags in head or body sections.

2. Variables and Data Types

• Variables: A variable stores data. Declared using var keyword. Rules: must start with alphabet,
case-sensitive, no spaces, cannot use keywords.

• Example: var a; var x = 'Hello';

• Data Types:

• - Number: Stores integers/decimals. Example: var y = 10000;

• - String: Stores text in quotes. Example: var str = 'Hello';

• - Boolean: true or false.

• - null: Represents nothing/empty.

• - undefined: Declared but not assigned value.

• - Infinity: Result of division by zero. Example: 3/0 = Infinity.

3. Operators

• Arithmetic Operators: +, -, *, /, %. Example: 40+4.5=44.5

• Assignment Operator: = assigns values. Example: var p = 400;

• Relational Operators: <, >, ==, != compare values. Result is true/false.


• Logical Operators: && (AND), || (OR), ! (NOT).

• Increment/Decrement: ++, -- for increasing/decreasing values. Pre and Post examples.

4. Functions and Control Structures

• Functions: Reusable block of code defined with function keyword.

• Decision Making: if, if-else for conditional execution.

• Loops: for and while for repeated execution.

• Built-in Functions: alert(), prompt(), confirm(), parseInt(), parseFloat().

You might also like