title: Javascript Can't catch an error inside map function
body: <p>let's say I have a usersList like this:</p>
  
  <pre><code>var usersList = [
              { firstName : 'Adam', lastName: 'Yousif', age: 23 },
              { firstName : 'Mohamed', lastName: 'Ali' },
              { firstName : 'Mona', lastName: 'Ahmed', age: 19 },
          ];
  </code></pre>
  
  <p>Now I want to call map function on usersList and return a modified list like so : </p>
  
  <pre><code>var returnList = usersList.map((_user) =&gt; {
              var _age;
              try {
                  _age = _user.age;
              } catch (error) {
                  console.log('I caught error here : ', error); // &lt;-- not printed
                  _age = 'FAILSAFE-VAULE'; // &lt;-- not set
              }
              var obj = {
                  firstName: _user.firstName,
                  lastName: _user.lastName,
                  age: _age
              }
              return obj;
          });
  </code></pre>
  
  <p>I have a try-catch block inside the map function, the purpose if it is to replace the undefined property "age" of the second user with a <code>'FAILSAFE-VALUE'</code>. but it doesn't work as should.</p>
  
  <pre><code>console.log(returnList);
  // prints
  // [ 
  //     { firstName: 'Adam', lastName: 'Yousif', age: 23 },
  //     { firstName: 'Mohamed', lastName: 'Ali', age: undefined }, &lt;-- not what I want
  //     { firstName: 'Mona', lastName: 'Ahmed', age: 19 } 
  // ]
  </code></pre>
  
  <p>How to catch an error inside javascript map function?</p>
  
  <p>Thank you</p>