Javascript中的构造函数和其他的函数本质上的区别是什么呢?我随便new一个函数会有什么结果呢?
解决方案 »
- 'null'为空或不是对象
- 地图上只显示一个不能点击的坐标点
- 如何判断3个数值的大小
- js代码改变动画src的问题
- 一连串的setTimeout,要clear其中的一个该怎么做?
- 这个怎么实现啊 在线等
- 请问大牛们,onbeforeunload在firefox下的如何判断刷新和关闭事件
- 框架顶页中的菜单项被底页覆盖通过什么方法可以显示出来?
- 请问怎样字符串格式化成规定格式的日期型?
- ■■请教:jscript里window.open(urlname,'',outerWidth:1000px;outerHeight:5000px;)改变窗口大小参数,不起作用啊,总是默认大小,怎么
- javascript继承问题
- 怎么使用jsmin!网上说的不够明确!
如果是这样,那函数中的那些代码与这个new出来的对象是什么关系呢?
希望高手能深入分析一下。
{
this.testName = "aa";
alert(this == window);
alert(window.testName);
}if you directly call the SuperTab, will alert true and "aa", because the scope is window for now.if you new the SuperTab, will alert false and "undefined", because the scope is SuperTab, the variable "testName" is avaiable in the SuperTab.
你就把构造函数当成一般面向对象语言里面的构造函数好了, 用 new调用函数,来产生类的实例
I nerver seen the english guide for Javascript, it was written by me, I am interesting the Javascript so much, please let me know if you have any questions about Javascript. My personal website is: http://www.scriptlover.com
然后在 这个最初的对象上面调用构造函数, 类似与 构造函数.call(o) 这样
且新对象能共享构造函数的原型对象中的属性
Are you studying English now?I'm curious about the way you reply my questions,you know,I mean why you use English instead of Chinese.