Javascript: nesting of private functions - good or bad?

Viewed 4593

I'm frequently using this structure:

var example = (function () {
    function privateFn2 () {
       ...
    }
    function privateFn1 () {
       ...
    }
    return {
        publicMethod1: function () {...
        },
        publicMethod2: function () {...
        }
    };
}());

What I want to know is this: If privateFn1 is the only function/method that calls privateFn2, is it regarded as better practice to set it up as follows?

EDITED for clarity

var example = (function () {
    function privateFn1() {
        function privateFn2() {
        }
        ...
        privateFn2();
    }
    return {
        publicMethod1: function () {...
        },
        publicMethod2: function () {...
        }
    };
}());

This is a wildly simplified example, of course. The issue is that I have lots of private functions, and I'm wondering whether nesting is well- or poorly-regarded. I recognise it is quite possibly a matter of preference, but any advice will be gratefully received.

Thanks.

2 Answers
Related