Based on the online tools, I think the best way to work around the JavaScript problem is to calculate the Age based on Birth and Death in terms of years and days.
See this online tool: https://rechneronline.de/year-of-birth/age.php
Using this method in your form will provide the most accurate result.
When done by hand here's how to: https://blog.eogn.com/2020/05/26/calculating-birth-dates-from-death-date-information/
But you'll notice that it is also going to be a little off in terms of days because of leap year, rollover dates, and the fact that not all months end on the 31st day. All of these things come into play when developing the date arithmetic. JavaScript doesn't make any these any easier due to the way it handles floating points, for example.
So we need to add an additional field for days, and possibly another field for the months using the arithmetic formula provided in my second link above.
Here are some info on how to calculate leap years https://www.htmlgoodies.com/html5/javascript/learn-how-to-use-javascript-dates-and-leap-years.html
I'm not good at calculating dates but maybe you could use something like this:
if(age >= 4){var age2 = age/4;}
var age3 = age2*86400;
var age4 = ((((diff-age3) / 60) / 60) / 24) / 365
event. value = Math.floor(age4);
this worked for me unless diff is less then 4 years, although this intrigue me, unfortunately I don't have much time to play with this but hope you can worked something from it.