javascript prototype原形链
解决方案 »
- ifream实现跨域请求遇到的问题,帮忙下~~~~~~~~~~~~~~~~~
- 如何从一个字符串构造出html对象来?
- 在jsp页面不用异步,js怎样得到后台传给前台的list?
- 懦懦问一下
- 请问只能输入0到1之间(包括0和1两个整数)的小数的正则表达式怎么写? 马上给分!!!!!!
- 请问可不可以删除HTML中的控件啊,譬如说Input
- 页面中两个<iframe>框架A、B,如何将A做成导航栏,B做成结果显示页?
- 高手求教!微软中国主页左侧的导航栏是怎么做出来的?
- 如何用javaScript弹出一个具有“是”,“否”,“取消”三个按钮的对话框?
- 一个不大不小的问题,关于新闻图片!!!
- js浏览器 兼容问题。八百里加急!
- Ext desktop 动态加载模块问题 !
var objA=function(str){
this.a='1234';
this.b=str;
this.fun1=function(){alert('This is a function');};
}objA.prototype.trim=function(str){return str.replace(/^\s*|\s*$/g,"");}var a=" asdf 注意两边的空格 1111 ";
var b="66666 1111 ";
var newo=new objA(a);
alert('a = ['+a+']\n\nb = ['+b+']\n\n'+newo.a+'\n\n应用trim后:['+newo.trim(a)+']');
</script>
var foo = function () { }
var bar = new foo();
foo.value = 5;
alert(foo.value);//值为5
bar.value = 6;
alert(bar.value);//值为6
bar.mymethod = function () { }//为函数赋值
bar.mymethod();//调用方法
foo.prototype.othervalue = 6;
alert(bar.othervalue);//显示6
</script>如上所示,我给原始对象foo的原型添加了新的属性,而在已有的对象bar里一样可以使用新的属性!希望对您有用!
我就是不知道那个_proto_是什么意思?如果有一个function test(){}
它会有一个name属性,值为函数名test 即test.name=="test"
test还有一个constructor属性,他是指向他的构造函数的.... 即test.constructor 指向 Function
test还有一个__proto__属性,他指向他的构造函数的原型 即test.__proto__===Function.prototype
ps: Function.__proto.__,Object.__proto__都是function(){} 不指向任何构造函数
它还有一个prototype属性 ; 即test.prototype={}
这里的函数原型指什么呢?
test.prototype={} 中的 {}指什么?
test.__proto__===Function.prototype 这个就是父原型链了吗?Function.prototype