JavaScriptの基本(クラスの基本)
/**
* Created with JetBrains WebStorm.
* User: bao_bao
* Date: 2013/03/31
* Time: 22:07
* To change this template use File | Settings | File Templates.
*/
var Helloworld = function()
{
console.log("hogehogefooo");
// publicプロパティ
this.x = 0;
this.y = 0;
//=========================================================
// PUBLIC METHOD
//=========================================================
this.position = function(x, y)
{
this.x = x;
this.y = y;
}
this.toString = function()
{
console.log(privateMethod() + "::x:" + this.x + "::y:" + this.y);
}
//=========================================================
// PRIVATE METHODS
//=========================================================
var privateMethod = function()
{
return "private method";
}
}
var h = new Helloworld();
h.position(30, 40);
h.toString();