![]() |
|
|
Advanced Web Design | ||
| Web Design Program | |||||
|
|
Scripting Database |
|
|||
|
Popular Javascript Functions |
|||||||||||||||||||||||||||||||||||
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.
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. The examples collected are relevant scripts that can be used in every day web sites. Each example is complete with code and a working demo.
|
||||||||||||||||||||||||||||||||||||