js 语法 new function与function
来源:互联网 发布:八爪鱼采集器的源码 编辑:程序博客网 时间:2024/06/05 09:37
By the Javascript spec, when a function is invoked with new, Javascript creates a new object, then sets the "constructor" property of that object to the function invoked, and finally assigns that object to the name this. You then have access to the this object for the body of the function.Once the function body is executed, Javascript will return:ANY object if the function manually returns one:function Car(){ this.num_wheels = 4; return {num_wheels:37};}var car = new Car();alert(car.num_wheels); // 37!The this object if the function has no return statement OR if the function returns a value of a type other than objectfunction Car() { this.num_wheels = 4; return 'VROOM';}var car = new Car();alert(car.num_wheels) // 4alert(Car()); // No 'new', so this alerts 'VROOM'
0 0
- js 语法 new function与function
- js中function与new function
- js中function new function new Function
- function 与 new function 区别
- function, new function, new Function
- function, new function, new Function
- function, new function, new Function
- function, new function, new Function
- Function 与 new Function 的区别
- new function(){}与function(){}() 闭包区别
- attachEvent与new Function,js给事件加参数
- new Function()
- new Function
- function,new function,new Function对比
- function,new function,new Function对比
- function,new function,new Function对比
- 关于function,new function 和 new Function
- js立即执行函数: (function ( ){})( ) 与 (function ( ){}( ))
- count(*),count(1),count(col)的区别
- 欢迎使用CSDN-markdown编辑器
- LightOJ 1148 - Mad Counting【数学】
- [读取文件数据],open()的返回类型和【list.append(),造成显性写入\n】。方法参数的缺省带来的影响?
- 操作系统进程环境
- js 语法 new function与function
- 初探GCD
- java面试宝典
- HDU1069 Monkey and Banana
- php连接MySQL失败问题解决
- js高级编程-10-DOM
- LeetCode 104:Maximum Depth of Binary Tree
- C#与Java泛型的比较
- 大数乘法——POJ2389