What does the colon operator do in this context?

I watched a code snippet How to subtract date / time in javascript? which looks 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 that means (date: Date): number, since I’ve never seen anything like it, and I know that it doesn’t look like ECA6 or anything else since the message was made in 2011

+4
source share
2 answers

This is TypeScript. This is a function that takes a type parameter dateand returns anumber

+3
source

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

+3
source

Source: https://habr.com/ru/post/1623134/


All Articles