In a simple HTML page, I have some JS like below
<script>
let users;
axios.get(url)
.then((resp) => {
users = resp.users;
})
// other stuff
</script>
users
is now accessible to access in console since it's on the window object. Would wrapping all that logic in an IFFE protect it from being accessible?
<script>
(function() {
let users;
axios.get(url)
.then((resp) => {
users = resp.users;
})
// other stuff
})();
</script>