JS is a client side scripting language.
The browser on the client's machine will run the script.
It will help a web master to do more using the standard HTML and CSS.
<html>
<head/>
<body>
<script type="text/JavaScript">
<!--
document.write("how are you")
//-->
</script>
</body>
</html>
- Make sure that the 'javascript' is enabled in your browser.
- javascript - related functions can be put in the header, body or separate file (.js), as required.
- <script src='jsfilename.js'/>
- You may not need to write all the javascripts your self as pre written functions are available on website for free. Just download/copy to use and modify if required !
- We do not necessarily use a semi colon if we write separate statements on separate lines. Use of semicolon (;) is mandatory if many js statements are written on the same line.
Various functions, operators (arithmatic etc.) and variables are used:
- var var1=5; var var2=12; var answ=var1+var2;
- document.write(answer is = ); document.write(answ);
- same variable can take as many values in a script as we want while we go on writing a script.
- javascript variables cannot be reserved words, cannot start with numbers, good to use underscore and good to start with a lower case alphabets(a-z).
List and Types of operators are:
- arithmetic... - * + / %
- assignment... =
- comparison... == != <= >= < >
Functions in javascript is used by writing:
- function funcname1() {put all the statements for functions in curly braces here}
- we can use functions in functions.
- functions are used by calling them with their name funcname1() where required.
Events in javascript are one of the most exciting things:
- javascript has a lot of predefined events and their names.