如何避免在我的团队成员中重新输入相同的功能?该say_name
函数可供团队 obj 中的所有成员使用。如何编写我的代码?
<script type="text/javascript">
var team={
// member
jimmy:{
name:'jimmy',
say_name:function (){}
},
darcy:{
name:'darcy',
say_name:function(){}
},
// common functions
say_name: function(){
// every member has the say_name function, I don't want to write the same code in each member. How to do?
alert('my name is ??')
}
}
</script>