javascript: how to access the functions from the console

when you are programming and want to test a function of your code inside the console, can you call it directly?

the answer here:

If the function global scope then it should be fine. If it is inside a function, then it will not work. In my case, I am using $(document).ready ( { function ( …) }); to hold all the code so I cannot. Now I understand why.

Two possible solutions: 

– copy paste the function in the console – may not work..

– or enclose it in this code:

(function() {
    window.myFunction = myFunction;
    function myFunction() {

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s