How to write auto execute javascript code ?
We can achieve it by 2 method.
1- Standard auto execute function.
2- Arrow function.
Standard auto execute function.
<script>
(function() {
const iamvar1= 'Iam var 1';
console.log('Auto Execute 1 function');
})();
</script>
Arrow function.
<script>
(()=> {
const iamvar2= 'Iam var 2';
console.log('Auto Execute 2 function');
})();
</script>
0 comments:
Post a Comment