|
Variables and String examples
| Language: |
JavaScript |
Unrated
Rated by 0 Users
1 Star = Horrible 5 Stars = Perfect
Rate Code Now
|
| Posted By: |
Blake |
| Author Website: |
Differences between ASP and PHP |
| Posted On: |
8/27/2007 |
| Code Views: |
575 |
This just shows how to initialize a variable, and manipulate it in different ways.
|
<script type="text/javascript"> // This is a comment, because of the two slashes
// The next line shows how to initialize a variable var variableName;
// After initialized, we can add data to it variableName = "Data, string here"
// We can then tack more onto it variableName = variableName + "More Data Here!"
// Then to write the variable, use document.write document.write(variableName);
// To initialize a variable and also add data you can do this var anotherVariable = "default data";
</script>
View code in Textarea
This code has not been tested by Your WebCode. Use it at your own risk.
Please report any copyright violations.
|
| Reviews |
|
Hide Reviews |
Add Review |
Delete Review
|
Posted by bass_tones on 8/30/2007Good example, you should also state you can add to a string using the following sytnax.
variableName += More Data Here!;
Also be sure to use simicolons as the end of lines ';' |
|