Smart Way to truncate string in javascript and adding ellipsis three dots in between the string

Welcome to Toppersarena.com Forums Programming Blogs Smart Way to truncate string in javascript and adding ellipsis three dots in between the string

This topic contains 0 replies, has 0 voices, and was last updated by Admin admin 1 year, 8 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3018
    Admin
    admin
    Keymaster

    var name= ” abcdefgh”;
    console.log(name.substring(0,2)+’…’+name.substring(name.length-3,name.length));

    OUTPUT:
    ab…fgh

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.