Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

different getters js

var log = ['test'];
var obj = {
  get latest () {
    if (log.length == 0) return undefined;
    return log[log.length - 1]
  }
}
console.log (obj.latest); // Retornará "test".
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #getters #js
ADD COMMENT
Topic
Name
4+6 =