module.exports Short usage in Javascript

module.exports is mainly used for exporting functions or data from a Module. It is basically done using module.exports keyword. This can be now shortened and used.

So here we are sharing a sample shortened use of the module.exports for exporting.

Instead of the module.exports , just exports can be used now as a short version.

Eg:

exports.getDate = function(){
    const today = new Date();

    const options = {
        weekday: "long",
        day: "numeric",
        month: "long"
    };

    return today.toLocaleDateString("en-US", options);
}

About the Author: smartcoder

You might like

Leave a Reply

Your email address will not be published. Required fields are marked *