Example

Date example

// You can get a Date instance using the new keywordletnow=newDate();console.log(now.getMonth());// Prints '3'console.log(now.toString());// Prints 'Mon Apr 11 2016 13:26:07 GMT+0100 (BST)'// You can get a string of the current date using Date as a function:letnowStr=Date();console.log(nowStr);// Prints 'Mon Apr 11 2016 13:26:07 GMT+0100 (BST)'

It is currently possible to implement something like that using new.target (see example in proposal) and this new feature makes it available for ES2015 classes.

A date implementation could be:

classDate{constructor(){// ...}callconstructor(){letdate=newDate();returndate.toString();}}letnow=newDate();// Get a Date instanceletnowStr=Date();// Use the 'call constructor()' part to get a string value of the current date