Last active
August 29, 2015 14:04
-
-
Save tweeeety/44f457a77660cd438797 to your computer and use it in GitHub Desktop.
judgement of object at javascript. sample01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 定義側 | |
var SomeThing = function(opt) { | |
// ※1 ここでとりあえずオブジェクト({})であることを保障したい | |
if( !opt ) 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