|
JavaScript is a scripting language which is similar in syntax to Java. The JavaScript code is embedded within the HTML file and is interpreted by the client browser. JavaScript brings interaction to the web pages. Using JavaScript, it is possible to customize HTML documents on the fly, write event handlers for elements on a page, validate data at the client side and perform other client-side computations. To view the various JavaScript examples, you need a JavaScript capable browser . I have tested my code only using Internet Explorer 3. If you find that any of the samples are not working properly, please mail me. About the languageJavaScript is a dynamically typed language. This means that data types in Javascript are not fixed but are automatically converted from one to other as required. For example, you could saymyData = 10;
in one line initializing the value of myData to an integer,
and in the next line, say myData = "Hello World!" setting
the value of myData to a string. Javascript will automatically
convert data types within expressions if necessary. So if you say
myData = "10" - 2;, you will end up with 8. Javascript
automatically converts "10" to 10 and does the
integer subtraction. If you are wondering why Javascript does not convert
2 to "2" instead, it is because the operator
- is not defined for strings and hence "10" - "2"
does not make any sense. This brings us to another interesting situation.
The operator + is defined both for numbers and strings. So
will 10 + "20" return 30 (10+20) or "1020"
("10" + "20"). It turns out that whenever you mix numbers and strings
and use the + operator, Javascript will always convert everything
to string before evaluating. Thus 10 + "20" is the same as
"10" + "20" and will evaluate to "1020".
JavaScript is case sensitive. Thus Due to the security built into JavaScript, it is highly unlikely that JavaScript code can do damage on your system. So you can run them without worry. My JavaScript samplesAll the samples given here are small and simple. If you find any of them useful, feel free to copy it on your page. Drop me a mail and include the location of your page if possible. If you like this site, consider giving me a link. |
|