摘要:
function Animal(){ this.species = "动物";}function Cat(name, color){ this.name = name; this.color = color;}Cat.prototype = new Animal();Cat.prototype.constructor = Cat; //重新把Cat的构造函数指回Catvar c2 = new Cat("大黄", "黄色滴");console.log(c2.name);console.log(c2.species);console.lo 阅读全文
posted @ 2013-05-16 16:52
践道者
阅读(194)
评论(0)
推荐(0)
摘要:
function Cat(name, color){ this.name = name; this.color = color;}Cat.prototype.type = "猫科动物";Cat.prototype.eat = function(){ console.log("吃鱼吃老鼠");}var c1 = new Cat("Tom", "black");console.log(c1.type);c1.eat();//检测类与对象人性关系:isPrototypeOfCat.prototype.isPrototyp 阅读全文
posted @ 2013-05-16 16:20
践道者
阅读(169)
评论(0)
推荐(0)
摘要:
function Shape(){ var init = function(){ } //模拟构造函数 init(); this.x = 1; //公有属性 this.y = 2; this.draw = function(){ console.log( this.x + this.y); }; //公有方法}var ashape = new Shape();console.log(ashape.x);ashape.draw();类属性\方法的定义:Shape.count = 10Shape.staticMethod = function(){} 阅读全文
posted @ 2013-05-16 13:56
践道者
阅读(168)
评论(0)
推荐(0)
摘要:
var mongodb =require('mongodb');var server = new mongodb.Server('localhost', 27018, {auto_reconnect:true});var db = new mongodb.Db('mydb', server, {safe:true});db.open(function(err, db){ if(!err){ console.log('connect'); }else{ console.log(err); }}); 阅读全文
posted @ 2013-05-16 11:19
践道者
阅读(4460)
评论(1)
推荐(0)
浙公网安备 33010602011771号