Link to home
Start Free TrialLog in
Avatar of Simon Leung
Simon Leung

asked on

Angular Expression Query

What does the actual code perform  ? From my guessing
#1 Array(Math.ceil(this.repo.movies.length/ this.repo.pagination.moviesPerPage))  ==> 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.length
                / this.repo.pagination.moviesPerPage))
                .fill(0).map((x, i) => i + 1);
        } else {
            return [];
        }
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Simon Leung
Simon Leung

ASKER

so, X is the current value of the array and i is the array index, correct ?

Thx
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.