我在阅读《JavaScirpt入门经典(第5版)》时,研究到了以下代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chapter2, Example1</title>
</head>
<body>
<script>
function createPerson(firstname, lastname)
{
return
{
firstName: firstname,
lastName: lastname,
getFullName: function()
{
return this.firstName + " " + this.lastName;
},
greet: function(person)
{
alter("Hello, " + person.getFullName() + ". I'm " + this.getFullName());
}
};
}
var johnDoe = createPerson("John", "Doe");
var janeDoe = createPerson("Jane", "Doe");
johnDoe.greet(janeDoe);
</script>
</body>
</html>
其中这一句
lastName: lastname,
我在chrome浏览器上调试,爆出了这样的错误
请问这是什么问题?