2019 version (if anyone wants to calculate the date of week's start)
The answer of Elle is pretty much right, but there is one exception:
if you want to get a date of start of the week - it won't help you because Elle's algorithm doesn't mind the day, from which the week starts of, at all.
And here is why:
Elle's solution
function getDateOfWeek(w, y) {
var d = (1 + (w - 1) * 7); // 1st of January + 7 days for each week
return new Date(y, 0, d);
}
Here you basically just calculating the amount of days from the start of the year (1st January). This means that it doesn't matter from which day your year starts of: Monday, Sunday or Friday - it will not make any difference.
To set the day, from which your week will start of (let's say Monday, for example), you just need to:
function getDateOfWeek(w, y) {
let date = new Date(y, 0, (1 + (w - 1) * 7)); // Elle's method
date.setDate(date.getDate() + (1 - date.getDay())); // 0 - Sunday, 1 - Monday etc
return date
}