<script> var str="hello"; var s="故事的结尾,心上人"; console.log(handleStr(s)); //输出: 故事的结尾... function handleStr(value){ if(value.length>5){ return value.slice(0,5)+"..."; } return value } </script>