Question: I have the following method from my controller that gets the data from the site:

```php
$goutteClient = new Client();
$guzzleClient = new GuzzleClient([
   'timeout' => 60,
]);
$goutteClient->setClient($guzzleClient);
$crawler = $goutteClient->request('GET', 'https://html.duckduckgo.com/html/?q=Laravel');
$crawler->filter('.result__title .result__a')->each(function ($node) {
    dump($node->text());
});

```

The above code gives me the title of contents from the search results. I also want to get the link of the corresponding search result. That resides in class `result__extras__url`.

How do I filter the link in and the title at once? Or do I have to run another method for that?

Answer: 
`map` only visits entries that actually exist, it skips gaps in sparse arrays.

There are various ways to do this:

1. You can use [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) and its mapping callback:

```js
const as = Array.from(Array(4), (_, index) => index + 1);

console.log(as);
```
2. You can use a simple `for` loop:

```js
const as = [];
for (let index = 1; index <= 4; ++index) {
    as.push(index);
}

console.log(as);
```
3. You can use [`fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype/fill) and then `map`:

```js
const as = Array(4).fill().map((_, index) => index + 1);

console.log(as);
```
4. A variant of `fill`+`map`, you can use spread as [Igor shows](https://stackoverflow.com/a/62757553/157247).
```
[...Array(4)].map((v, i) => i + 1)

```