0đź‘Ť
Javascript has a built-in function for this.
If you’re sure the variable is always Number and never a “number String”, you can do:
product.price.toLocaleString()
If you want to be safe, do:
Number(product.price).toLocaleString()
Source:stackexchange.com