mtbink.com logo

JavaScript notes

  1. Format number:
    (123456789).toLocaleString()
    will returns
    123,456,789
  2. Padding 0:
    (123).toString().padStart(6, "0")
    will returns
    000123
  3. Padding spaces:
    (123).toString().padStart(6)
    will returns
       123
  4. Check is substring exists:
    ("abcde").includes("bc")
    will returns
    true
  5. Check if an item exists in an array:
    ["a","b","c"].includes("b")
    will returns
    true
  6. Check if string starts with:
    "abcde".startsWith("abc")
    will returns
    true
  7. Check if string ends with:
    "abcde".endsWith("cde")
    will returns
    true

Share:



Flag Counter