Please do not click on this text.... External Javascript File Inline Code Event Handler"> Please do not click on this text.... External Javascript File Inline Code Event Handler">
Download presentation
Presentation is loading. Please wait.
1
CS 142 Lecture Notes: JavascriptSlide 1 Simple Javascript Example sum = 0; for (i = 1; i < 10; i++) { sum += i*i; }
2
CS 142 Lecture Notes: JavascriptSlide 2 Factorial in Javascript function fac(x) { if (x <= 1) { return 1; } return x*fac(x-1); }
3
CS 142 Lecture Notes: JavascriptSlide 3 Embedding Javascript... //<![CDATA[ alert("Page is loading"); //]]> Please do not click on this text.... External Javascript File Inline Code Event Handler
4
CS 142 Lecture Notes: JavascriptSlide 4 Method Example Object o = new Object(); o.count = 0; o.increment = function(inc) { if (inc == undefined) { inc = 1; } this.count += inc; return this.count; }
5
CS 142 Lecture Notes: JavascriptSlide 5 Constructor function Rectangle(width, height) { this.width = width; this.height = height; } r = new Rectangle(26, 14);
6
CS 142 Lecture Notes: JavascriptSlide 6 Prototypes function Rectangle(width, height) { this.width = width; this.height = height; } Rectangle.prototype.area = function() { return this.width*this.height; } r = new Rectangle(26, 14); a = r.area();
7
CS 142 Lecture Notes: JavascriptSlide 7
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.