<script> function myClass(){ this.id=1 this.str="abc" } c=new myClass() alert(c.constructor) for(ob in c)alert(ob) </script>
<script language=javascript> function myobj(){ this.aa="asdf" this.bb="fff" } var s="myobj" var test=eval("new " + s) for(p in test){ alert(p) } </script>
第二个问题还没有答案呢, 如何根据一个具体的对象来得到他的function的名称?在就是通过一下语句得到的包括了这个对象所有的属性,方法以及具体值,有什么办法能把上诉三者区分呢? for(p in test){ alert(p) }
就是秋水说的constructorfunction AA() { this.v=3; } var a=new AA(); var b=new a.constructor(); alert(b.v);
new Funciont("...") ∧ ∧ ( ⊙_⊙ ) 祝所有人好运!我会天天Happy的。
<script> function myClass(){ this.id=1 this.str="abc" this.func=go } function go(){ alert(); } c=new myClass() for(ob in c)if(typeof(c[ob])!="function")alert(ob) </script>
利用秋水所说的函数的constructor属性可以得到函数名: <script> function myClass(){ this.id=1 this.str="abc" } c=new myClass() var str = "" + c.constructor; var index = str.indexOf("("); alert(str.substring(8, index)); </script>
function myClass(){
this.id=1
this.str="abc"
}
c=new myClass()
alert(c.constructor)
for(ob in c)alert(ob)
</script>
function myobj(){
this.aa="asdf"
this.bb="fff"
}
var s="myobj"
var test=eval("new " + s)
for(p in test){
alert(p)
}
</script>
如何根据一个具体的对象来得到他的function的名称?在就是通过一下语句得到的包括了这个对象所有的属性,方法以及具体值,有什么办法能把上诉三者区分呢?
for(p in test){
alert(p)
}
{
this.v=3;
}
var a=new AA();
var b=new a.constructor();
alert(b.v);
∧ ∧
( ⊙_⊙ ) 祝所有人好运!我会天天Happy的。
function myClass(){
this.id=1
this.str="abc"
this.func=go
}
function go(){
alert();
}
c=new myClass()
for(ob in c)if(typeof(c[ob])!="function")alert(ob)
</script>
<script>
function myClass(){
this.id=1
this.str="abc"
}
c=new myClass()
var str = "" + c.constructor;
var index = str.indexOf("(");
alert(str.substring(8, index));
</script>