摘要:
请将All over the world people enjoy sports替换成All1 over2 the3 world4 people5 enjoy6 sports7大牛的实现:var i = 0, str = "All over the world people enjoy sports";str = str.replace(/\S+/g, function($){return $ + [++i]});alert(str); 阅读全文
摘要:
var a = 1;function test(){ alert(a); var a = 2;} test();运行的结果是undifined.不是2.js 的执行过程中,编辑器先以读入代码段,对代码段中的var 变量和function 定义进行“预解析”,预解析var 变量的时候,初始化为undefined相当于一下代码:var a = 1;function test(){ var a; alert(a); a = 2;}test(); 阅读全文