13TH DAY AT UKI
JAVASCRIPT
1. There are a number of different places where Javascript can be used but the most common place to use it is in a web page.
1. There are a number of different places where Javascript can be used but the most common place to use it is in a web page.
The HTML defines what the content is.
CSS defines the appearance of a web page.
Javascript adds behavior to the web page.
JAVASCRIPT VALUES
The javascript syntax defines two types of values:
1.fixed values
fixed values are called literals.
2.variable values
variable values are called variables.
JAVASCRIPT VARIABLES
Javascript variables are containers for storing data values.
All javascript variables must be identified with unique names.These unique names are called identifiers.
Names for variables are :
1.contain letters,digits,underscores and dollar signs.
2.Names must begin with a letter.
3.Names can also begin with $.
4. Names are case sensitive.
5.reserved words are cannot be used as names.
In javascript, the equal sign(=) is an "assignment" operator, not an "equal" operator.
The "equal" operator is written like == in javascript.
EXAMPLE:
var price1=5;
var price2=6;
var total=price1+price2;
JAVASCRIPT DATA TYPES
Javascript variables can hold many data types:numbers,strings,objects.
Examples:
1.Number
var length=16;
2.String
var lastname="johnson";
3.Objects
var X={firstname:"john",lastname:"doe"};
In programming,data types are important concept.
To be able to operate on variables,it is important to know something about the type.
Javascript evaluates expressions from left to right.
Different sequences can produce different results:
var X=16+4+"volvo";
results:20volvo
var X="volvo"+16+4
results:volvo164
Since the first operand is a string, all operands are treated as strings.
Javascript has dynamic types.
This means that the same variables can be used to hold different data types:
var X;
Now X is undefined.
var X=5;
Now X is a number.
var X="john";
Now X is a string.
No comments:
Post a Comment