私有属性(私有变量和私有方法)
实例属性(实例变量和实例方法)
静态属性(静态变量和静态方法)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
function Test(){
var color = "blue";
var fn = function() //私有函数
{
}
}
function Test2(){
this.color = "blue";
this.fn = function() //实例函数
{
}
}
function Test3(){}
Test3.color = "blue";
Test3.fn=function(){}
console.log(typeof Test3.fn)
function Obj(){
this.a=[];
this.fn=function(){
}
}
var o1=new Obj();
o1.a.push(1);
o1.fn={};
console.log(o1.a);
console.log(typeof o1.fn);
var o2=new Obj();
console.log(o2.a);
console.log(typeof o2.fn);
function f1(argument) {
this.name="lxm";
this.show = function (argument) {
console.log("I am previous function")
}
}
var objF1 = new f1();
objF1.show = function (argument) {
console.log("I am later function ");
}
objF1.show()
</script>
</head>
<body>
</body>
</html>