1. 程式人生 > >Node 基礎

Node 基礎

bject PE on() prot AD name this type user

Node 創建對象的方法

1.

var User = new Object();

User.first = "Brad";

User.second = "Balyley";

User.getName = function(){ return this.first + " " + this.second;}

2.

var User = {

  first:‘Brad‘,

  second:‘Balyley‘,

  getName:function(){return this.first + " " + this.second}

}

3.

function User(first,second){

  this.first = first;

  this.second = second;

  this.getName = function(){this.first + " " + this.second;}

}

4.

funciton User(first,second)

{  

  this.first = first;

  this.second = second;

}

User.prototype = {

  getName:function(){

    return this.first + " " + this.second;

}

}

Node 基礎