function createPerson(name, age) { var obj = { name: name; age:age; } return obj; } var p1 = createPerson('111', 25); var p2 = createPerson('222', 44); console.log(p1); console.log(p2); ========================================================
为什么这样写会报错?
function createPerson(name, age) { var obj = { name: name; age:age; } return obj; }
========================================
为什么这样写是对的?
function createPerson(name, age) { var obj = { } obj.name=name; obj.age=age; return obj; }
聪明的汤姆
相关分类