I've something like
let myFunction;
$(document).ready(function() {
    myFunction = function(param) {
        // ...
    }
});
and inside my HTML, I have
<a href="javascript:void(0);" onclick="myFunction(1)">...</a>
Now it says Uncaught ReferenceError: myFunction is not defined.
let myFunction;
$(document).ready(function() {
    myFunction = function(param) {
        console.log('running');
    }
});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="javascript:void(0);" onclick="myFunction(1)">...</a>OK, so what I tried was:
$(document).ready(function() {
    function myFunction(param) {
        // ...
    }
});
but again, Uncaught ReferenceError: myFunction is not defined. I've no idea, really, I used the first piece of code for a long time now and all of a sudden, that doesn't work anymore (or not in my context, or what ever). What's the correct approach to this?
I created a JSFiddle to show that what I tried doesn't work indeed (expected output is 1 or 2 in an alert, error given): https://jsfiddle.net/kgdcwe4z/5/
 
     
    