point.x=3; //property
point.y=4;
point.getPosition=function(){ //method
alert(this.x+","+this.y);
} ;
→ the result is 3,4
point.getPosition();
→ call the function. So from the example above, we'll get "3,4"
var trip=new Object();
trip.name="Couple Trip";
trip.score=70;
trip.outdoor=function(){ // Camping at outdoor so that we can enjoy natural environment.
this.score=this.score+10;
};
trip.rainyDay=function(){ //Rainy day is a bit troublesome that we can't go hiking.
this.score=this.score-5;
};
trip.snacksnBBQ=function(){ //Delicious food is always welcome!
this.score=this.score+20;
};
trip.napping=function(){ //Chilled camping always needs a nap.
this.score++;
};
trip.report=function(){ //
alert(this.name+":"+this.score)
};
So at the end, the way we count the score of an ideal trip would be...
trip.outdoor();
trip.rainyDay();
trip.snacksnBBQ();
trip.napping();
trip.report();
→ The result is 96!
Feel free to comment and share your ideas below to learn together!
If you guys find this article helpful, please kindly do the writer a favor — LIKE this article.
>>: Day 20. Hashicorp Nomad: Docker driver image behavior
这个API可以取得总金额的排名, 步骤如下: (1)汇入需要的库 import shioaji as...
前言 我们已经知道了组成一个简单的 CNN 做 classification 所需要的部件了,那麽接...
想要降刷 macOS 版本,或是处理 Fusion Drive,该怎麽办?那里有资源?或是那边有官方...
前言: RecyclerView 可以轻松高效地显示大量数据。 RecyclerView回收这些单独...
前言 上一回我们将词性标签依序排列建构出片语组块( phrase chunk ),描绘出相应的分析树...