- It can be embedded directly into your XHTML page
- It is a lightweight scripting language
- Unlike Java, it can execute without having to compile.
- This means that it is an interpreted language
Java was developed by Sun Microsystems, and is a much more powerful and complex language
Java must be compiled into ‘machine language’
Doesn’t allow for reading/writing of files on client machine
Java is object-oriented, applets consist of object classes with inheritance
- Put dynamic elements into an HTML page
- React to user or page events.
- Read and write HTML elements
- Validate data
- Detect the users browser
- Create cookies
- If you have a simple script that you want to be executed when the page loads, place it within the <body> section with the <script>….</script> tags
- If you have a script that is to be loaded when it is called or an event triggered, put it in the <head> section again within <script>….</script> tags or use an external .js file.
- Execution path can be tricky, need to ensure element exists before operating on them
Variables are “containers” for storing information.
A letter (like x) can be used to hold a value (like 5)
You could use the information above to calculate the value of a to be 6?
A variable can have a short name, like x, or a more descriptive name, like speed.
Variable names are case sensitive (y and Y are two different variables)
Variable names must begin with a letter, the $ character, or the underscore character
Variable Declaration (var)
You can also assign values to the variables when you declare them:
When you assign a text value to a variable, use “quotes” around the value.
Boolean values true, false e.g.