JS: Calling a function from within that function, when dealing with multiple instances <p>How do I call a function from within the function, when I have multiple instances of that function?</p> <p>I know I can simply call the function from within:</p> <pre><code>$(".mCSB_container").sortable({ revert: true, scroll: true, update: function( event, ui ){ new update(param1); }, }); function update(param1){ if (updating){ //If I'm already updating, I want to wait for that update to be finished setTimeout(function(){ update(param1); }, 100) } else { updating = true; //Proceed with the update //... postUpdate(); } } function postUpdate(){ $.ajax({ url: '/update', type: 'POST', dataType: 'json', async: true, data: postData, success: function (data) { //... updating = false; return data; }, error: function (data) { //refresh page return false; } }); } </code></pre> <p>Now I'm trying to get my head around how instantiation works in JS. I know I can create a new instance simply by calling <code>new update(param1);</code>, but then what's going to happen in the timeout when I try to call the update function? I can always just create a new instance every time, but isn't that inefficient?</p> <p>If I could just call the same instance from within the instance that seems like it would be ideal.</p> <p>Thanks for any help, I greatly appreciate it.</p>