javascript : Number.format(strFormat)

javascript : Number.format(strFormat)


Target:

Applicable with Number Data Type.


Description :

format Number to string with given format string.


Note: strFormat should to matched with regular Expression "/^([0#,])+([.]){0,1}([0])*$/" other wise return toLocalString().



Syntax:

Number.format(strFormat)


Usase:

  1. (123456.123456).format("##,##,##0.00") //Currency
    It return string "1,23,456.12"
  2. (123456.123456).format("00000000000") //pad zero
    It return string "00000123456"
  3. (123456545).format("00000000000.00") //pad zero + decimal
    It return string "00123456545.00"
  4. (123456545).format("0.00") //Fixed Decimal Places
    It return string "123456545.00"
  5. (123456.545).format("0.00") //floating point round in decimal places
    It return string "123456.55"



Download MYJS.js

MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type. 

Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.

Comments

Popular posts from this blog

javascript : String.right

javascript : String.left

javascript : .nextAll()