创建对象时new子的作用

来源:互联网 发布:用java编写游戏脚本 编辑:程序博客网 时间:2024/04/28 01:05
<!DOCTYPE html><html><head><title>test</title></head><body><script type="text/javascript">function f(){this.name = "test";this.age = 13;}var a = f();// 未使用 new // window 何其冤 被增加了两个属性console.log(a); //undefinedconsole.log(window.name);  //testconsole.log(window.age)  //13</script></body></html>

0 0
原创粉丝点击