1

With the code below would I need to worry about other scripts (external or inline) overriding my function and variables? Or as this is within the jQuery( function( $ ) { function is myfunction and myVariable unique to that block of code?

<script>

    jQuery( function( $ ) {

        function myfunction() {

            console.log( 'test1' );

        }

        myfunction();

        var myVariable = 'test2';

    });

</script>
bigdaveygeorge
  • 947
  • 2
  • 12
  • 32
  • 1
    jQuery( function( $ ) { creates a closure making the function and variable inside inaccessible outside that closure and if duplicates exist at higher level the ones inside closure will shadow them – charlietfl Aug 08 '21 at 12:31

0 Answers0