Interesting JS (jQuery-UI) problem
Hi all,
Now I write one widgets library and I use jQuery-UI for base. But yesterday I get one interesting problem. :). Watch this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title> ===== Interesting JS Bug ==== </title>
<script type="text/javascript">
var cls = function (){
this._init();
}
cls.prototype = {
items : [],
_init : function (){
for(var i=0;i<5;i++){
this.items.push(i);
}
}
}
var obj_1 = new cls(); alert(obj_1.items.join(':')); // result (0,1,2,3,4)
var obj_2 = new cls(); alert(obj_2.items.join(':')); // result (0,1,2,3,4,0,1,2,3,4)
// ### NICE :) ###
</script>
</head>
<body></body>
</html>
This problem is not only for jQuery-UI but i saw it when made the my widgets.