Documente Academic
Documente Profesional
Documente Cultură
Writing Code
1.Code is written in text format
2.Consists of statements, block consists of set of statements, variables ,immediate values
3.Statement-Consists of one or more items or symbols.
-Every new line is a new statement
-Also we can use semicolon Jscript terminator(;)
4.Block- A group of statements surrounded by some braces are called block.
-Used to create a function or conditional statements.
5.Comments-Single line Eg: //comments
-Multi line Eg: /* comments */
can be written as series of single line comments.
6. Assignemnts and equality ’ = ‘ symbol is used to assign a value to a variable
(name=”Senthil”)
‘==’(double equal to symbol) is used to compare any two
values whether they are equal or not
7.Expression valid combinations of variables, values ,operators, expressions
Eg: a= b+c
B= (a+c)*c
Jscript Variables:
1.Variables are used to store the values in the script.
2.Can retrieve and manipulate values.
3.Declaring variable Not necessary.But declaring is a good practice
use Var for declaring the variables.
Eg: var mim=”India”
4.Naming VariablesJscript a case sensitive scripting language. So “var Com” is not
“var com”
The variable name must start with a character or underscore or $
Subsequent letters can be characters, numbers, underscore or $
No reserved words should be used.
Valid variable names: Country, _Country,$country,
invalid variable names: 8country, count&ry, var
If not assigned with any values but declared means, it will exists
in script.But undefined.
If not assigned means we can assign as “null”(var colo=”null”)
But without assigning and declaring we should not keep any
variable. Jscript will throw run time error
Eg: function test()
{
Var country //correct
State=”Andhra” //correct
City //Wrogn. It can be var city or assigned
with values
}
5.Coercion- Automatic conversion of type of variables.
-The variables take types equivalent to the type of values stored in it.
-Also the coercion or type conversion is automatic some restrictions are
There
-Numbers can easily included in strings . But strings cannot included in
numbers directly
-We need to use parseInt (), parseFloat() functions to include strings into
number
-Eg: var a=10
Var b=”1”
Var c= 0
c += b+c //This will give the result c=0110.The string b is not
included in numbers. a,c also converted to strings.
c += parseInt(b)+c //This will give the result c=11;
Jscript Functions:
1.Function performs some actions.
2.Returns values.
3.Get values-> Called arguments or parameter
4.Function may be with or without arguments.
5.Two type of functions: Built into the language, User defined.
Jscript Objects:
1.