日期:2014-05-16 浏览次数:20343 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">当alert完两句执行完,两个实例还存在吗,什么时候被回收?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type='text/javascript'>
var $ = function( selector, context ) {
return new $.prototype.init( selector, context);
};
$.prototype.init = function(name, age) {
this.name = name;
this.age = age;
};
$.prototype.init.prototype = $.prototype;
var person = $('zhangsan', 18);
var persons = $('lisi', 19);
alert(person.name);
alert(persons.name);
/*$.dom = function(name, age) {
var result = new $();
result.name = name;
result.age = age;
return result;
};
$.prototype.sayName = function() {
alert(this.name);
return this;
};
var person = $('zhangsan', 18);
var persons = $('lisi', 19);
person.sayName();
persons.sayName();*/
</script>
</head>
<body>
</body>
</html>