2014年7月19日土曜日

javascript オブジェクト 作成、プロパティ、メゾット

javascript オブジェクト 作成、プロパティ、メゾット


<script text="text/javascript">

var j = function (e){
        var x=0;
        var opt = {};

        opt.a =function (){
                x=x+1;
                return x;
  }();

        opt.b = function(){
                x=x-1;
                return x;
        };

        opt.c = function(){
                return "opt.c";
        };

        opt.d = function(){
                return "opt.b";
  }();

        opt.e = function(x){
                console.log(x);
                console.log(e);
                return x;
        };

        opt.f = function(x){
                return x;
        }(e);

        return opt;
}("引数");

</script>


実行の結果:



0 件のコメント: