Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

(intermediate value).getdate is not a function

//case 1
const logger = function () {
  console.log('hi');
} // missing semicolon here

(function () {})();
//correct
const logger = function () {
  console.log('hi');
};

(function () {})();
//case 2
const obj = {
  getNum() {
    return 5;
  },
  sum(a) {
    // TypeError: (intermediate value).getNum is not a function
    return a + super.getNum();
  },
};

console.log(obj.sum(10));

//correct
const obj = {
  getNum() {
    return 5;
  },
  sum(a) {
    // Works (Use this, not super)
    return a + this.getNum();
  },
};

console.log(obj.sum(10));
 
PREVIOUS NEXT
Tagged: #function
ADD COMMENT
Topic
Name
2+4 =