는 또한 크롬의 자바 스크립트 콘솔에서이 자바 스크립트를 테스트하고이 코드를catch되지 않은 구문 에러 : 리터럴 객체에서 예기치 않은 식별자는
"use strict";
var myObject = {
foo: 'bar',
talk : function(){
console.log('Hello world')
}
}
myObject.talk();
console.log(myObject.foo);
그러나 경우 작업 Uncaught SyntaxError: Unexpected Identifier
을 반환 내가 function talk(){}
"use strict";
var myObject = {
foo: 'bar',
function talk(){
console.log('Hello world')
}
}
myObject.talk();
console.log(myObject.foo);
위의 오류 012를 throw합니다.. 미리 감사드립니다.
개체에 'function talk()'를 지정하지 않았습니다. – Chad
같은 속성, 당신은 객체에 대한 메소드를 만든다 :'talk : function() {};'당신은 myObject와 같은 메소드를 호출한다.이야기(); – Michelangelo
@Chad 어떻게 고칠 수 있습니까? 고맙습니다. –