Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active December 7, 2018 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/64c29c3d0163dd0a5740 to your computer and use it in GitHub Desktop.
Save baobao/64c29c3d0163dd0a5740 to your computer and use it in GitHub Desktop.
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment