📜  javascript 用省略号截断 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:14.903000             🧑  作者: 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...