Monday 23 December 2013

Introduction to javascript

Introduction to javascript : 1

Javascript is a very easy to learn language.

1. Printing text to console:
write the text in double quote which you want to print to console
ex. "This text will be printed on console";

2. Counting length of the string:
use length function to count the length of the string
ex. "sample".length;

3. Data types in javascript:
There are data types in many languages like numbers, string etc.
In JavaScript also there are data types like numbers and string.
The numbers written without double quotes are number ex. 43, 78.9.
The text written within double quotes are considered as string ex. "43", "javascript"

4. confirm function :
Confirm function is used to take response from the user for a particular action.
A confirm box appears on the screen with some display text, ok and cancel button.
ex. confirm("try again?");

5.Prompt function :
Prompt function provides interaction with user. It provides a input box to take input from the user.
ex. Prompt("What is your name?");

No comments:

Post a Comment