1. Regular expressions
1
2
3
4
//删除开头和结尾所有的空格  
function trim(str) {  
return str.replace(/(^\s+|\s+$)/g,'');
}
1
2
3
4
5
6
7
注: 
^ 开头
$ 结尾
\s 空格匹配
+ 多次出现     
g 全文匹配
i 忽略大小写  
  1. setTimeout(message, 3000);

Execute the function message once after 3 seconds. If you want to repeat the execution, you need to call setTimeout again in the message function