📜  带有省略号的 javascript 最大长度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:38.685000             🧑  作者: Mango

代码示例1
function truncate_with_ellipsis(s,maxLength) {
   if (s.length > maxLength) {
      return s.substring(0, maxLength) + '...';
   }
   return s;
};
alert(truncate_with_ellipsis("hello how are you today?",9));//hello how...