I am trying to understand recursion and tail call optimization. I have this example code below and it seems not to be TCO. Why is it not and how can I change it to be optimized?
const getState = () => {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://stackoverflow.com', true);
xhr.onload = () => console.log(xhr.response);
xhr.send();
};
(function updateState() {
getState();
setTimeout(updateState, 1000);
})();