json 包含字段及函数的写法
在javascript中写类有多种方式: 1.function()中嵌套function; 2.prototype的方式 ,3.json的方式,如下: <script language="javascript"> var Mouse={ m_name:"Big Mouse", m_age:1, getName:function(){ return Mouse.m_name; }, getAge:function(){ return Mouse.m_age; }, setName:function(str_name){ Mouse.m_name=str_name; } }; var m_name=Mouse.getName(); var alert_=""; alert_+=m_name+" , "; Mouse.setName("Small Mouse"); m_name=Mouse.getName(); alert_+=m_name; alert(alert_); </script>