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