Simon Leung
asked on
Angular Expression Query
What does the actual code perform ? From my guessing
#1 Array(Math.ceil(this.repo. movies.len gth/ this.repo.pagination.movie sPerPage)) ==> Create a array of elements depending on expression result
#2. .fill(0) ==> Fill up each array element with 0
#3 .map((x, i) => i + 1 => What does it want to do ???
get pages(): number[] {
if (this.repo.movies != null) {
return Array(Math.ceil(this.repo. movies.len gth
/ this.repo.pagination.movie sPerPage))
.fill(0).map((x, i) => i + 1);
} else {
return [];
}
#1 Array(Math.ceil(this.repo.
#2. .fill(0) ==> Fill up each array element with 0
#3 .map((x, i) => i + 1 => What does it want to do ???
get pages(): number[] {
if (this.repo.movies != null) {
return Array(Math.ceil(this.repo.
/ this.repo.pagination.movie
.fill(0).map((x, i) => i + 1);
} else {
return [];
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
so, X is the current value of the array and i is the array index, correct ?yup.
and because we filled the array with 0 (.fill(0)), so all the values of the array are identical as 0.
ASKER
Thx