CS174
Chris Pollett
Oct. 11, 2010
<script type="text/javascript"> <!-- hide from old browsers -- code -- // --> </script>
<script type="text/javascript" src="myscript.js" />
return x; // has the effect of just return!
<html> <head><title>test</title> <meta name="description" value="this example illustrates how Javascripts are executed both when the document is loaded and on the occurrence of events" /> <script type="text/javascript" ><!-- function sayHello() { alert("hi there"); } //--> </script> </head><body><form><input type="button" value="test" onClick="return sayHello();" /><!-- responds to events --></form> <script type="text/javascript" ><!-- for( i = 0; i<100; i++) { document.writeln("<p>hi"+i+"</p>"); } // run when document loads --> </script></body> </html>
Which of the following statements is true?
var myVariable, pi=3.14; // explicit declarations effect the scope of the variable
first = "hello" second = first + "bye" // "hellobye"
"August" + 1977 // "August1977" 1977 + "August" // "1977August" 7*"3" =21
var str_value = String(value); // Might want to use toString var number = Number(aString); // Might want to use parseInt or parseFloat