Last active
August 29, 2015 14:04
-
-
Save tweeeety/d8bc2458871376afbb9a to your computer and use it in GitHub Desktop.
judgement of object at javascript. sample07
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) { | |
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