DEV Community

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

madeinmilwaukee profile image
Chuck Watson

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

waqarhusain profile image
Waqar Hussain • Edited on

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.