Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

JavaScript

on

  • 752 views

 

Statistics

Views

Total Views
752
Views on SlideShare
745
Embed Views
7

Actions

Likes
0
Downloads
2
Comments
0

1 Embed 7

http://vacuum.vbox.lt 7

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

JavaScript JavaScript Presentation Transcript

  • JavaScript Felix Dahlke November 2010 update FSI Köln
  • DOM → window → document → html → head → title → body →p
  • Funktionen/Variablen function f() { } var x = 5; var y = “Hello, World”;
  • Funktionen/Variablen var myAlert = function(s) { alert(s); } function sayHello(f) { f(“Hello, World!”); } sayHello(myAlert);
  • JSON var konto = { nummer: “133713371337”, saldo: 1300, inhaber: [“Felix”, “John”] };
  • Literals “Hello” // string true // boolean 1 // number 1.0 // number [1, 2] // array {number: 5} // object /^d{1,4}$/ // regular expression
  • Bedingungen, Schleifen etc. if (true) {} while (true) {} for (var i = 0; i < 10; i++) {} for (x in [1, 2, 3]) {} switch (…) {...}
  • Scope function f() { if (true) { var x = 15; } alert(x); // Funktioniert }
  • Typen function Konto(saldo) { this.saldo = saldo; } Konto.prototype = { abheben: function(betrag) { this.saldo -= betrag; } }; var k = new Konto(1000); k.abheben(300); // k.saldo == 700
  • Vererbung function Girokonto(saldo, dispoLimit) { Konto.call(this, saldo); // Super-Konstruktor this.dispoLimit = dispoLimit; } Girokonto.prototype = new Konto(); Girokonto.prototype.abheben = function(betrag) { if ((this.saldo + this.dispoLimit) < betrag) throw “Dispo-Limit erreicht :(“; Konto.prototype.abheben.call(this, betrag); }; new Girokonto(50, 200).abheben(300);
  • Monkey Patching Date.prototype.print = function() { alert(this.toUTCString()); } var d = new Date(); d.print();
  • jQuery $(“div>p:first-child”) <div> <p>Hello</p> <p>World</p> </div>
  • jQuery $(“div>p:first-child”).css({ color: “Red”, “font-size”: “larger” });
  • jQuery $(“div>p”).hover(function() { $(this).toggleClass(“highlighted”); }).click(function() { alert(“Clicked!”); });
  • jQuery $(document.ready(function({ alert(“Ready.”) }); $(function() { alert(“Ready”) });