showing results for - "get js"
Zakaria
01 Jul 2016
1const obj = {
2  log: ['a', 'b', 'c'],
3  get latest() {     //get is used to return a value from your object
4    if (this.log.length === 0) {
5      return undefined;
6    }
7    return this.log[this.log.length - 1];
8  }
9};
10
11console.log(obj.latest);
12// expected output: "c"