json方式的面向对象

<script>
var p1= {
  name: 'blue',
  sex: '男',
  showName: function ()
  {
    alert('我的名字是:'+this.name);
  },
  showSex: function ()
  {
    alert('我的性别是:'+this.sex+'的');
  }
};

p1.showName();

p1.showSex();

</script>

posted @ 2017-04-26 20:55  少海  阅读(188)  评论(0)    收藏  举报