码迷,mamicode.com
首页 > 其他好文 > 详细

Node 基础

时间:2018-06-23 20:57:14      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:prot   bsp   obj   on()   second   func   name   nbsp   基础   

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 基础

标签:prot   bsp   obj   on()   second   func   name   nbsp   基础   

原文地址:https://www.cnblogs.com/ninjakim/p/9218418.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!