我一直在尝试在气体脚本文件中使用 Object.create。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 已定义,但它似乎并没有按预期工作。这是一个错误还是我错过了什么?