当前位置: 代码迷 >> JavaScript >> javascript的函数传值有关问题
  详细解决方案

javascript的函数传值有关问题

热度:201   发布时间:2012-09-09 09:27:54.0
javascript的函数传值问题
想做一个函数abc(a,b,c)
能用var f=new abc()
f.a=asdfasd
f.b=asdfasd
f.c=fasdf
将abc值写到网页里,如何做?

------解决方案--------------------
JScript code
      function abc(a, b, c) {
          this.a = a; this.b = b; this.c = c;
          this.toString = function () { return this.a + '<br/>' + this.b + '<br/>' + this.c; }
      }
      var f = new abc();
      f.a = 'a'; f.b = 'b'; f.c = 'c';
      document.write(f.toString()) 
  相关解决方案