- Joined
- Apr 6, 2016
- Messages
- 278
- Reaction score
- 161
- First Language
- Swedish
- Primarily Uses
- N/A
Is there anyway without using "try" to perform the below line, where it doesn't fail if
The error is as follows, I naturally know what it means, but I'll include it anyways.
I am looking for something along the lines of
Edit:
I thought the following might work, but yeah, as I feared, even though the try statement is within the loop, it does break the loop.
Best regards,
Bishiba
filter
doesn't return a weapon?
JavaScript:
for (var i = 1; i < 8; i++) if ($gameActors.actor(i).weapons().filter(weapon => weapon.name == $dataWeapons[21].name)[0].name) {true} else {false}
The error is as follows, I naturally know what it means, but I'll include it anyways.
JavaScript:
Uncaught TypeError: Cannot read property 'name' of undefined
at <anonymous>:1:93
I am looking for something along the lines of
if (€Array.name)
, where "€" would essentially imply if does not exist, just continue. I know € does not exist, it's an example.Edit:
I thought the following might work, but yeah, as I feared, even though the try statement is within the loop, it does break the loop.
JavaScript:
for (var i = 1; i < 8; i++) try {if ($gameActors.actor(i).weapons().filter(weapon => weapon.name == $dataWeapons[21].name)[0].name) {true} else {false} } catch(e) {console.error(e)}
Best regards,
Bishiba
Last edited: