有时候JS类似于面向对象,有时候JS又不是面向对象。

因为js中没有类和对象的概念,类和对象都是通过函数闭包来模拟出来的。

1、下面我们先写一段js,如下

function Cat(){

this.Name=\'Mimi\';

this.Age=\'2\';

this.sayHello=function(){

alert(\'my name is\'+this.name+\'I\'m\'+this.Age);

}

}

</script>

可以看到 在此js中定义[……]

更多