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,210
  • 7
  • 21
  • 35

2 Answers2

3

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

bcr
  • 3,791
  • 18
  • 28
3

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

BiAiB
  • 12,932
  • 10
  • 43
  • 63