javascript intro
javascript intro
JavaScript:
Features of JavaScript
<script>
function abc(){
var x=10; // local variable
}
</script>
Global variable:
A JavaScript global variable is accessible from any function.
A variable i.e. declared outside the function or declared with window object is
known as global variable.
<script>
var data=200;//gloabal variable
function a(){
document.writeln(data);
}
function b(){
document.writeln(data);
}
a();//calling JavaScript function
b();
</script>
Javascript Data Types:
Data types in JavaScript refers to the types of the values that we are
storing or working with.
One of the most fundamental characteristics of a programming
language is the set of data types it supports.
These are the type of values that can be represented and
manipulated in a programming language.
JavaScript provides different data types to hold different types of
values. There are two types of data types in JavaScript.
1. Arithmetic Operators
2. Comparison (Relational) Operators
3. Bitwise Operators
4. Logical Operators
5. Assignment Operators
6. Special Operators
JavaScript Arithmetic Operators
Arithmetic operators are used to perform arithmetic operations on the
operands. The following operators are known as JavaScript arithmetic
operators.
JavaScript Comparison Operators
The JavaScript comparison operators compare two values and returns
a boolean result (true or false).
JavaScript supports the following comparison operators
JavaScript Bitwise Operators
The JavaScript bitwise operators are used to perform bit-level
operations on integers.
JavaScript supports the following seven types of bitwise operators
JavaScript Logical Operators
The logical operators are generally used to perform logical
operations on boolean values. But logical operators can be applied to values
of any types not only boolean.
JavaScript supports the following logical operators
JavaScript Assignment Operators
In JavaScript, an assignment operator is used to assign a value to a
variable. JavaScript supports the following assignment operators
JavaScript Special Operators
There are few other operators supported by JavaScript. These
operators are conditional operator (? :), type of operator, delete operator,
etc.