<!doctype html>
<html>
<script>
var Class = (function(){
var list = {
ABC : 'ABC',
DEF : 'DEF'
}
var ctor = function(){};
ctor.getContent = function(value){
return list[value];
}
return ctor;
})();
alert(Class.getContent('ABC'));
</script>
</html>
本文展示如何在JavaScript中创建类、定义属性,并通过构造函数获取类属性的值。
717

被折叠的 条评论
为什么被折叠?



