Skip to content

Instantly share code, notes, and snippets.

@yardfarmer
Created August 19, 2014 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yardfarmer/f3561136754092e443e3 to your computer and use it in GitHub Desktop.
Save yardfarmer/f3561136754092e443e3 to your computer and use it in GitHub Desktop.
构造自己的类
/**
* Class build my Own class
* Created by cyk on 14-8-19.
*/
/*
* 很巧妙的办法
*/
var Class = function() {
"use strict";
var klass = function() {
// this 均是上下文中新生成的实例
this.init.apply(this, arguments);
};
klass.prototype.init = function() {};
return klass;
};
var Person = new Class();
Person.prototype.init = function() {
"use strict";
};
var person = new Person();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment