Lecture Notes for CS349W
Fall Quarter 2008
John Ousterhout
sum = 0; for (i = 1; i < 10; i++) { sum += i*i; }
new Array(); ["a", 123, 65]
function fac(x) { if (x <= 1) { return 1; } return x*fac(x-1); }
fac = function(x) {...};
new Object() {name: "Alice", age: 23, state: "California"}
o = new Object(); o.name = "Alice"; o["age"] = 23;\
Object o = new Object(); o.count = 0; o.increment = function(inc) { if (inc == undefined) { inc = 1; } this.count += inc; return this.count; }o.increment() returns 1
function Rectangle(width, height) { this.width = width; this.height = height; } r = new Rectangle(26, 14);
Rectangle.prototype.area = function() { return this.width*this.height; }
<script type=\"text/javascript\"> //<![CDATA[ Javascript goes here... //]]> </script>
<script type="text/javascript" src="code.js"></script>