📜  不同的getter js - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:52.483000             🧑  作者: Mango

代码示例1
var log = ['test'];
var obj = {
  get latest () {
    if (log.length == 0) return undefined;
    return log[log.length - 1]
  }
}
console.log (obj.latest); // Retornará "test".