Last active
August 29, 2015 14:09
-
-
Save monkindey/883712e33671bdef932a to your computer and use it in GitHub Desktop.
code self-introduction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author: monkindey | |
* @date: 2014-11-15 | |
* @descripion: 用面向对象的代码来介绍自己 | |
*/ | |
! function() { | |
// HELPER | |
function extend(sup, overrides) { | |
var sub = overrides && overrides.constructor || function() { | |
sup.apply(this, arguments); | |
}; | |
var fn = function() {}; | |
var subp; | |
fn.prototype = new sup; | |
subp = sub.prototype = fn.prototype; | |
subp.constructor = sub; | |
apply(subp, overrides); | |
sub.superClass = sup.prototype; | |
return sub; | |
} | |
function apply(o, c) { | |
if (o && c && typeof c == 'object') { | |
for (var p in c) { | |
o[p] = c[p]; | |
} | |
} | |
return o; | |
} | |
function FrontEnder() { | |
this.skills = ['HTML', 'CSS', 'JavaScript']; | |
} | |
apply(FrontEnder.prototype, { | |
code: function() { | |
console.log('我能编写处理业务逻辑代码'); | |
}, | |
paint: function() { | |
console.log('我能还原设计稿'); | |
}, | |
debug: function() { | |
console.log('我能使用工具调试代码'); | |
} | |
}); | |
var Me = extend(FrontEnder, { | |
constructor: function() { | |
// 个人的性格是怎么样的?等完善 | |
var _character = ''; | |
return function Me(config) { | |
config = config || {}; | |
Me.superClass.constructor.call(this); | |
this.skills = this.skills.concat(['HTML5', 'CSS3', 'Grunt', 'Zepto', 'Webapp', 'ChromeDevtool']); | |
apply(this, config); | |
} | |
}(), | |
paint: function() { | |
Me.superClass.paint.call(this); | |
console.log('我可以用CSS3、HTML5还原设计稿'); | |
}, | |
code: function() { | |
Me.superClass.code.call(this); | |
console.log(function() { | |
/** | |
1. 根据规范来命名如驼峰、_、$等; | |
2. 使用闭包来避免变量污染; | |
3. 相同处理逻辑代码抽出来作为一个功能模块; | |
4. 避免与HTML、CSS产生耦合; | |
5. 注意代码的性能优化 | |
*/ | |
}.toString().split('\n').slice(2, -2).toString().replace(/\t/g, '').split(',').join('\n')) | |
}, | |
manage: function() { | |
console.log('我有一个属于自己的代码库和记录知识点的博客'); | |
}, | |
habit: function() { | |
console.log('twitter、HTML5Rock、CSS3-trick、W3.org...'); | |
}, | |
enjoy: function() { | |
console.log('我喜欢打篮球和看NBA,最喜欢的球员是Steve·Nash'); | |
} | |
}); | |
var me = new Me({ | |
ChineseName: '张楷豪', | |
EnglishName: 'monkindey', | |
Birthday: '1993-07', | |
Email: '[email protected]', | |
School: '广东工业大学计算机学院网络工程 11级' | |
}); | |
console.dir(me); | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment