Monday, 20 May 2013

Basic Concepts of Javascript

Statement- A statement ends with semicolon, Statement is typically a single line of js, It's not a rule to break statement across multiple lines.

Examples

hours=now.getHours();
mins=now.getMinutes();
sec=now.getSeconds();


Functions:



See my previous post about Functions(Freind-add, freind-subtract):

http://javascriptwithshrinivas.blogspot.com/2013/05/about-objects.html

Functions means you assigned task, That will accomplished by functions

document.write("Wish");

Above display output to web page.


and some functions return a value

ext=prompt(" Enter some text");

Above prompt function ask you to enter some text. That text stored in ext variable.



You can also create your own functions. To avoid re coding in program, See previous post Friend-add
You can use (call) this function more times.

Objects: See my previous post
http://javascriptwithshrinivas.blogspot.com/2013/05/about-objects.html

JavaScript supports 3 kinds of objects


1).Built-in objects: JavaScript has some built in objects Like Date () ... etc. Built-in means you need not to implement anything just use it. Date () is best example.

2).DOM: Many times we used document.Write function.
In this write is method and document is object (write method belongs to document object).
We can use various components of HTML and BROWSER. Best example is alert method. It's method of window object

3). Custom objects:- Your own creation.

If else statements:


if (count==1) alert(" The countdown has reached. ");;

Above if count increases to 1 then popup box display with above message 
else not(if count==0)

Loops

for(i=1;i<=5;i++)
{
Alert("Hi. Welcome to http://javascriptwithshrinivas.blogspot.in/");

}





















No comments:

Post a Comment