0% found this document useful (0 votes)
2 views

Javascript

JavaScript is a high-level, versatile programming language primarily used for creating interactive web pages and applications, originally developed by Netscape in 1995. It features dynamic typing, object-oriented programming, and can be embedded in HTML, making it essential for web development. Key concepts include variable declaration with var, let, and const, various data types, and arithmetic and comparison operators.
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)
2 views

Javascript

JavaScript is a high-level, versatile programming language primarily used for creating interactive web pages and applications, originally developed by Netscape in 1995. It features dynamic typing, object-oriented programming, and can be embedded in HTML, making it essential for web development. Key concepts include variable declaration with var, let, and const, various data types, and arithmetic and comparison operators.
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/ 8

Introduction to JavaScript

1. What is JavaScript?
• JavaScript is a high-level, versatile, and dynamic
programming language primarily used for building
interactive web pages and web applications.
• It's often referred to as the "language of the web"
because it's the most common scripting language used
in web development.
2. History of JavaScript:
• Developed by Netscape Communications Corporation,
led by Brendan Eich in 1995.
• Initially named "LiveScript" but later renamed JavaScript
for marketing purposes.
• Standardized as ECMAScript.
3. JavaScript in Web Development:
• JavaScript is primarily used to enhance the functionality
of web pages by adding interactivity and dynamic
behaviour.
• It can be embedded within HTML code and executed by
web browsers.
4. Features of JavaScript:
• High-level language: JavaScript abstracts many of the
low-level details, making it easier to write and
understand code.
• Interpreted: It's executed by the web browser without
the need for compilation.
• Dynamic and loosely typed: Variables can change types,
and you don't need to specify types explicitly.
• Object-oriented: JavaScript is centered around objects
and supports object-oriented programming.
• Cross-platform: Runs on all major web browsers and
platforms.

Variables in JavaScript:

• Variables in JavaScript are used to store data values. You


can think of them as containers that hold different types
of information. To declare a variable in JavaScript, you
can use the var, let, or const keywords.
1.var:

var was traditionally used for variable declaration, but it


has some scope issues and is less commonly used now

Example:
2. let:
o let allows you to declare block-scoped variables,
which means they are only accessible within the
block (e.g., inside a function or loop) where they
are defined.

Example:

3. const:
o const is used to declare constants. Once a value is

assigned to a const, it cannot be changed.

Example:

Data Types in JavaScript:


JavaScript has several data types to represent different
kinds of values. These data types include:

a. String:

o Represents textual data and is enclosed in single or


double quotes.
Example:
b. Number:

• Represents both integer and floating-point numbers.

c. Boolean:
• Represents true or false values.

Example:

d. Undefined:

• Represents a variable that has been declared but hasn't


been assigned a value.

e. Null:
• Represents the intentional absence of any object value.

Arithmetic Operators:

Arithmetic operators in JavaScript allow you to perform


mathematical calculations on numeric values. Here are the
most common arithmetic operators:

1. Addition (+): Adds two numbers together.

2.Subtraction (-): Subtracts the right operand from the left


operand.

3.Multiplication (*): Multiplies two numbers.


4. Division (/): Divides the left operand by the right
operand.

5.Modulus (%): Returns the remainder of the division of


the left operand by the right operand.

6.Increment (++) and Decrement (--): These operators


increase or decrease a variable by 1.

Comparison Operators:

Comparison operators in JavaScript are used to compare


values and return Boolean results (true or false). Here are
some common comparison operators:

1. Equal (==): Checks if two values are equal, but it doesn't


consider data types (type coercion).
2. Not Equal (!=): Checks if two values are not equal, with
type coercion.

3. Strict Equal (===): Checks if two values are equal and


have the same data type (no type coercion).

4. Strict Not Equal (!==): Checks if two values are not equal
or have different data types.

5. Greater Than (>): Checks if the left value is greater than


the right value.

6. Less Than (<): Checks if the left value is less than the
right value.
7. Greater Than or Equal (>=): Checks if the left value is
greater than or equal to the right value.

8. Less Than or Equal (<=): Checks if the left value is less


than or equal to the right value.

You might also like