TypeScript Ders Notları #3 Class Kullanımı
TypeScript:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://ercanbozkurt.blogspot.com */ | |
class Bilgi | |
{ | |
mesajMetni: string; | |
constructor(mesaj: string) | |
{ | |
this.mesajMetni = mesaj; | |
} | |
mesajVer() | |
{ | |
return "Merhaba! Mesajınız: " + this.mesajMetni; | |
} | |
} | |
let bilgi = new Bilgi("Ken'i seçme beni seç!"); | |
let btn = document.createElement('button'); | |
btn.textContent = "Tıkla"; | |
btn.onclick = function () | |
{ | |
alert(bilgi.mesajVer()); | |
} | |
document.body.appendChild(btn); | |
/* http://ercanbozkurt.blogspot.com */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://ercanbozkurt.blogspot.com */ | |
var Bilgi = (function () { | |
function Bilgi(mesaj) { | |
this.mesajMetni = mesaj; | |
} | |
Bilgi.prototype.mesajVer = function () { | |
return "Merhaba! Mesajınız: " + this.mesajMetni; | |
}; | |
return Bilgi; | |
}()); | |
var bilgi = new Bilgi("Ken'i seçme beni seç!"); | |
var btn = document.createElement('button'); | |
btn.textContent = "Tıkla"; | |
btn.onclick = function () { | |
alert(bilgi.mesajVer()); | |
}; | |
document.body.appendChild(btn); | |
/* http://ercanbozkurt.blogspot.com */ |
Hiç yorum yok:
Yorum Gönder