xxxxxxxxxx
let res = this.props.details?.substring(100, 0);
xxxxxxxxxx
Use optional chaining to check whether string to be truncated is availbale. (?)
let res = {movie.release_date?.substring(0, 4)};
//if release date was 2022-6-9 the result will be 2022