TypeScript kullanarak yazdığımız kodlar;
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 */ | |
console.log("Merhaba Dünya"); | |
console.log("TypeScript Öğreniyorum!"); | |
// TypeScript, değişken tanımlarken tip bildirimi yapmayı sağlar. | |
// Aşağıdaki örnekte string tipinde, tip güvenli bir değişken tanımlanmıştır. | |
var mesaj:string = "Merhaba Dünya"; | |
console.log(mesaj); | |
// Aşağıdaki örnekte number tipinde, tip güvenli bir değişken tanımlanmıştır. | |
var sayi:number = 12; | |
console.log(sayi); | |
//sayi = "araba"; // number tipinde bir değişkene string tipinde bir değer atanamaz. | |
// Tip güvenliği sayesinde bu işlem denetime takılır ve derleyici hata üreterek kodu derlemeyi reddeder. | |
class Selam { | |
selamVer():void { | |
console.log("Selâmün Aleyküm Dünya!"); | |
} | |
} | |
var slm = new Selam(); | |
slm.selamVer(); | |
/* 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 */ | |
console.log("Merhaba Dünya"); | |
console.log("TypeScript Öğreniyorum!"); | |
// TypeScript, değişken tanımlarken tip bildirimi yapmayı sağlar. | |
// Fakat, TypeScript ile yazılmış kodlar JavaScript'e dönüştürüldüğünde bildiğimiz JavaScript'ten farksızdır. | |
var mesaj = "Merhaba Dünya"; | |
console.log(mesaj); | |
var sayi = 12; | |
console.log(sayi); | |
var Selam = (function () { | |
function Selam() { | |
} | |
Selam.prototype.selamVer = function () { | |
console.log("Selâmün Aleyküm Dünya!"); | |
}; | |
return Selam; | |
}()); | |
var slm = new Selam(); | |
slm.selamVer(); | |
/* http://ercanbozkurt.blogspot.com */ |
Hiç yorum yok:
Yorum Gönder