Skip to content

Instantly share code, notes, and snippets.

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 tweeeety/d8bc2458871376afbb9a to your computer and use it in GitHub Desktop.
Save tweeeety/d8bc2458871376afbb9a to your computer and use it in GitHub Desktop.
judgement of object at javascript. sample07
// 定義側
var SomeThing = function(opt) {
if( !(opt instanceof Object && !(opt instanceof Array)) ) opt = {};
if( !opt.name ) opt.name = "noname";
if( !opt.sex ) opt.sex = 1;
this.opt = opt;
}
// 呼び出す側
var opt = {
"name" : "tweeeety",
"sex" : 1
};
var s = new SomeThing(opt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment