가스 스크립트 파일에서 Object.create를 사용하려고했습니다. Object.create가 정의되었지만 유용한 객체를 반환하지 않는 것 같습니다. 크롬 북에서 Chrome의 [google-apps-script] 스크립트 파일에서 Object.create 사용
function createOject() {
var o = Object.create({}, { p: { value: 42 } })
Logger.log(o.p); //logs 42.0 as expected
var db = ScriptDb.getMyDb();
db.save(o); //o still shows up as empty {} in the debugger and
//won't save to data store
showTable(); //logs nothing
}
이 코드
잘 작동 : 그래서function createOject() {
var o = {p: 42};
Logger.log(o.p); //logs 42.0 as expected
var db = ScriptDb.getMyDb();
db.save(o); //o shows up as an object {p: 42} in the debugger and
//saves to the the data store as expected
showTable(); //logs {p: 42} as expected
}
, Object.create가 예상대로 작동하지 않는 정의되어 있지만. 이게 버그 야? 아니면 내가 놓친 게 있니?
그러나 var prop = Object.getOwnPropertyNames (o); // 로그 [p] ??? – user1472330
당신은 정확합니다; 내 대답을 편집했습니다. –