
Javascript – Operatörler
Ağustos 29, 2022
Javascript – Hazır Nesneler
Ağustos 29, 2022Javascript - Nesnenin Özellikleri ve Metodları
<!DOCTYPE html>
<html>
<head>
<title>Ömer Turak - Javascript - Code 12</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/bootstrap.css">
<link rel="stylesheet" href="../css/bootstrap-theme.css">
</head>
<body>
<div class="container">
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Javascript Code Example 12 </h4> Javascript Create New Objects (Properties and Methods of Object) <a href="../index.html">Back Home</a>
</div>
<script type="text/javascript">
// Objelerin özellik ve metodları
// This global olarak kullanılır.
// obje içinde fonksiyon oluşturma. Objenin oluşturulan her fonksiyonu aynı zamanda onun bir özelliğidir.
var automobile = {
sahibi : "Omer",
marka : "BMW",
model : 2010,
km : 20,
fiyat : 20000,
start : function () {
alert("Car is Start...")
},
moveCar : function () {
alert("Car is move...");
},
break : function () {
alert("Car is break...");
},
stop : function () {
alert("Car is stop...");
},
carInfo : function () {
console.log("Araba sahibi :" + this.sahibi),
console.log("Marka :" + this.marka),
console.log("Araba model :" + this.model),
console.log("Km :" + this.km),
console.log("Araba fiyat :" + this.fiyat)
},
carAge : function () {
return 2018 - this.model;
}
}
console.log(automobile);
document.write(automobile.sahibi);
//change object
automobile.km = 200;
console.log(automobile.km);
document.write(automobile.km);
automobile.start();
automobile.moveCar();
automobile.break();
automobile.stop();
automobile.carInfo();
alert(automobile.carAge());
</script>
</div>
</body>
</html>