DEV Community

loading...

Discussion on: Two string methods every JavaScript developer should know.

Collapse
madeinmilwaukee profile image
Made in Milwaukee

Since you know the exact input maybe less is more here?
let date = '"2019-08-02T00:00:00.000Z"';
date = date.substr(1, 10);

Collapse
waqarhusain profile image
Waqar Hussain • Edited

Substr should not be used. Instead use substring


String.prototype.substr(…) is not strictly deprecated (as in "removed from the Web standards"), it is considered a legacy function and should be avoided when possible. It is not part of the core JavaScript language and may be removed in the future. If at all possible, use the substring() method instead.

developer.mozilla.org/en-US/docs/W...