Magento 2 Get Currency Symbol in JS File.

If you are looking to get the current currency symbol in Magento 2 JavaScript file and want a formatted price in Magento 2 JS file then this blog post is for you.

When you add the custom price somewhere on your Magento 2 quote, that price should be in the proper formats, like with a currency symbol, current store currency, and 2 decimal points. Magento provides Magenot_Catalog/js/price-utils JS file which does this for you.

The price-utils.js can be found at /vendor/magento/module_catalog/view/base/web/js/ directory.

The below code shows how to get the formatted price in Magento 2 JS file.

define([
    'jquery',
    'Magento_Checkout/js/model/quote',
    'Magenot_Catalog/js/price-utils'
], function ($, quote, priceUtils) {
    'use strict';
   
    function getCustomPrice()
    {
        var price = 10;

        return priceUtils.formatPrice(price, quote.getPriceFormat()); // Output like $10.00
    }
});

So this is how you can format price using price-utils and quote in Magento 2