What is line referencing? "est: isTouch // WEB.utils.tactus.est();"

Regarding the code below,  from this article https://blogs.perficient.com/perficientdigital/2017/11/21/detecting-the-use-of-a-touch-screen/  but I'm confused with this return code:
    // Reveal the methods
    return {
        isTouch: isTouch, // WEB.utils.tactus.isTouch();
        est: isTouch // WEB.utils.tactus.est();
    };

Open in new window

I'm confused what "est: isTouch // WEB.utils.tactus.est();"  (line 15 below)  is referencing and why both methods are revealed. They both return the same value.
var WEB = WEB || {};
WEB.utils = WEB.utils || {};
// Begin Tactus
WEB.utils.tactus = (function() {
    // Set variable to cache the results of isTouch
    var _isTouchCached = null;
    // Set a variable detecting the existence of touch events
    var _hasEvents = 'ontouchstart' in window || navigator.msMaxTouchPoints > 0;
    // Set a flag variable to keep track of if the mouse/touch event listeners were already added
    var _listenersAdded = false;
    // Call the isTouch method initially
    isTouch();
    // Reveal the methods
    return {
        isTouch: isTouch, // WEB.utils.tactus.isTouch();
        est: isTouch // WEB.utils.tactus.est();
    };
    // Default isTouch check
    function isTouch() {
        // If the cached variable already has a value
        if (_isTouchCached !== null) {
            // Just return the cached variable and don't bother checking again
            return _isTouchCached;
        }
        // If the browser supports touch events
        if (_hasEvents) {
            // If the mouse/touch event listeners haven't been added yet
            if (!_listenersAdded) {
                // Add the mouse/touch event listeners
                _addListeners();
            }
            // If the browser doesn't support touch events
        } else {
            // Set the cached variable to false
            _isTouchCached = false;
        }
        // Return the current value of the cached variable
        return _isTouchCached;
    }
    // The function to add the mouse/touch event listeners
    function _addListeners() {
        // If the mouse/touch event listeners haven't been added yet
        if (!_listenersAdded) {
            // Add the mouse event listener
            window.addEventListener('mousemove', _checkForMouse);
            // Add the touch event listener
            window.addEventListener('touchstart', _checkForTouch);
        }
        // Set the flag to true to indicate that the mosue/touch event listeners have been added
        _listenersAdded = true;
    }
    // The mouse event listener
    function _checkForMouse() {
        // Set the cached variable to false
        _isTouchCached = false;
        // Remove the mouse/touch event listeners
        _removeListeners();
    }
    // The touch event listener
    function _checkForTouch() {
        // Set the cached variable to true
        _isTouchCached = true;

        // Remove the mouse/touch event listeners
        _removeListeners();
    }
    // The function to remove the mouse/touch event listeners
    function _removeListeners() {
        // Remove the mouse event listener
        window.removeEventListener('mousemove', _checkForMouse);
        // Remove the touch event listener
        window.removeEventListener('touchstart', _checkForTouch);
    }
}());

Open in new window

894359Asked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
this :
    return {
        isTouch: isTouch, // WEB.utils.tactus.isTouch();
        est: isTouch // WEB.utils.tactus.est();
    };

Open in new window

same as :
    return { isTouch: isTouch,  est: isTouch };

Open in new window

or again :
   var obj = { isTouch: isTouch,  est: isTouch };
   return obj;

Open in new window


so you can use WEB.utils.tactus.isTouch or WEB.utils.tactus.est which are the same reference to the function isTouch inside the namespace WEB.utils.tactus
0
 
Juan OcasioConnect With a Mentor Application DeveloperCommented:
Both are referring to the isTouch function. So the isTouch function will be called with either:

WEB.utils.tactus.isTouch() or WEB.utils.tactus.est()
0
 
894359Author Commented:
So why do this? IS there any advantage?
0
 
Juan OcasioApplication DeveloperCommented:
No advantage. May be for compatibility so it doesn’t break anything that’s out there
0
 
leakim971PluritechnicianCommented:
a shortcut...? only Bryce Taylor know...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.