Safe way to declare a private function in Dojo

Pattern to create private functions in Dojo?

The Dojo documentation advocates the use of _underscore to denote a function as private, but this is obviously just a convention and doesn’t actually create a private function e.g.

  • Is there a way to remove a comma from dojo's NumberSpinner?
  • How to focus second Cell when add a new row in dojo.gridX
  • Dojo: Div Tag Issue
  • using static variables to initialize variables in the same class
  • Dojo and Firebug
  • Poll the Server with Ajax and Dojo
  • define([
       "dojo/_base/declare"
    ],
    function (declare) {
       return declare(null, {
    
           getPrivateData: function () {
               _myPrivateFunction();
           },
    
           _myPrivateFunction: function () {
               return "Data from private function";
           }
       });
    });
    

    I’ve looked at the questions on SO about private variables in Dojo, but none of them reflect my requirement. However, one of the answers to this question includes a sample from the Dojo documentation showing how to create a private class.

    My question is, is there any reason why the same pattern should not be used to create a private function? e.g.

     define([
    "dojo/_base/declare"
    ],
    function (declare) {
    
        var myPrivateFunction = function() {
            return "Data from private function";
        };
    
        return declare(null, {
    
            getPrivateData: function () {
                myPrivateFunction();
            }
        });
    
    });
    

  • Dojo: Can I add two or more widgets to the same BorderContainer region?
  • How to open a browser window without any bars like address bars, bookmarks bars etc in javascript?
  • How to set Arcgis Javascript dojoConfig relative path of packages
  • Adding a package to dojo config at runtime
  • how to format struts-dojo datetimepicker to show 24 hours instead of 12 hours?
  • How to load custom AMD modules when using Dojo via CDN?