4

I was looking at piece of code on How to subtract date/time in javascript? which is like

Date.prototype.diffDays = function (date: Date): number {

    var utcThis = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds(), this.getMilliseconds());
    var utcOther = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());

    return (utcThis - utcOther) / 86400000;
};

and I'm wondering what the (date: Date): number means since I've never seen anything like that and I know this isn't like ECA6 or whatever since the post was made in 2011

Community
  • 1
  • 1
Subpar Web Dev
  • 3,122
  • 5
  • 19
  • 33

2 Answers2

3

That's TypeScript. It's a function that accepts a parameter of type date and returns a number

Brian
  • 3,701
  • 16
  • 26
3

This is typescript (http://www.typescriptlang.org/), a superset of javascript that adds typing to variables, not pure javascript.

BiAiB
  • 11,493
  • 7
  • 40
  • 59