Skip to content
Mak Sò edited this page Mar 22, 2015 · 1 revision

String prototypes

  • capitalize

    Capitalize first letter in a word

    'test'.capitalize()

    result

    "Test"

  • capitalizeAll

    Capitalize all first letters of all word contained in a sentence separate by space

    'test test Test test'.capitalizeAll()

    result

    "Test Test Test Test"

  • getDateEU

    Convert new Date in european format date

    String(new Date).getDateEU()

    result

    dd/mm/yyyy

  • getDateUS

    Convert new Date in american format date

    String(new Date).getDateUS()

    result

    mm/dd/yyyy

  • getDbDate

    Convert Database formar date 2015-03-18T16:23:18.423Z in european format date

    '2015-03-18T16:23:18.423Z'.getDbDate()

    result

    dd/mm/yyyy

  • getDbDateTime

    Convert Database formar date 2015-03-18T16:23:18.423Z in european format date and time

    '2015-03-18T16:23:18.423Z'.getDbDateTime()

    result

    dd/mm/yyyy - hh:mm:ss

  • htmlEscape

    Convert normal string in a html string

    'Marco&Co'.htmlEscape()

    result

    Marco&Co

  • htmlUnescape

    Convert html string in a normal string

    'Marco&Co'.htmlUnescape()

    result

    Marco&Co

  • repeat

    Repeat a word 'n' times

    'test0'.repeat(3)

    result

    "test0test0test0"

  • reverseWord

    Reverse a word

    'test0'.reverseWord()

    result

    "0tset"

  • substringBeforeTo

    Return substring before an symbol

    'test0.test1'.substringBeforeTo('.')

    result

    "test0"

  • substringAfterTo

    Return substring after an symbol if the symbol is contained more times return an array

    • example 1

      'test0.test1'.substringAfterTo('.')

      result

      "test1"

    • example 2

      'test0.test1.test2.test3'.substringAfterTo('.')

      result

      ["test1","test2","test3"]

  • validateContent

    Validate content in a string

    • example 1

      'mak.so1979@gmail.com'.validateContent('email')

      result

      true

    • example 2

      'mak.so1979gmailcom'.validateContent('email')

      result

      false