How to fixed Uncaught TypeError: Constr is not a constructor Error in Magento?

Javascript console Uncaught TypeError: Constr is not a constructor error that will be seen when we have made some mistakes on the javascript file in Magento.

Error structure looks like,

layout.js:137 Uncaught TypeError: Constr is not a constructor
    at Object.initComponent (layout.js:137)
    at fire (jquery.js:3238)
    at Object.fireWith [as resolveWith] (jquery.js:3368)
    at Object.deferred.<computed> (jquery.js:3467)
    at fire (jquery.js:3238)
    at Object.fireWith [as resolveWith] (jquery.js:3368)
    at Object.deferred.<computed> [as resolve] (jquery.js:3467)
    at layout.js:120
    at Object.execCb (require.js:1650)
    at Module.check (require.js:866)

I have faced the above error when I deal with Magento_Ui/js/core/app custom components in my module.

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app" : {
                "components" : {
                    "favoriteItems": {
                        "component": "Rbj_Favorite/js/favorite-products"
                    }
                }
            }
        }
    }
</script>

Now When you create favorite-products javascript file in your module,

define([], function () {
    // your logic
});

I just forgot to return the function in the javascript file and throws that error on a console for me.

Resolution For Me:
Fixed by adding a return function in the custom js file.

define([], function () {
    return function () {
        console.log('JS Calling');
        // write your logic here.
    }
});

You must have to return function when you call custom component using Magento 2 require js approach.