皮皮网
皮皮网

【kdj软件源码】【顺天传奇源码】【站源源码】js源码打乱

时间:2024-12-28 18:26:40 来源:adb 源码瞎子啊

1.jsԴ?源码kdj软件源码????
2.js for in 和 for of的区别
3.js的push方法

js源码打乱

jsԴ?????

       你说的是这种效果吗?

<html>

           <head></head>

           <body>

               <div id="box"></div>

           </body>

           <script>

               (function(){

                     function Point(x, y, width, color, container)

                     {

                       this.instance = null;

                       this.x = x;

                       this.y = y;

                       this.width = width;

                       this.color = color;

                       

                       this.click = function()

                       {

                           this.instance.click();

                       }

                       if(Point.prototype.container == undefined)

                       {

                            Point.prototype.container = document.getElementById(container); 

                       }

                     }

                     Point.prototype.render = function()

                     {

                       var _this = this;

                       this.instance = document.createElement('button');

                       this.instance.style.position = "absolute";

                       this.instance.style.top = this.y;

                       this.instance.style.left = this.x;

                       this.instance.style.width = this.width;

                       this.instance.style.height = this.width;

                       this.instance.style.backgroundColor = this.color;

                       this.container.appendChild(this.instance);

                       this.instance.addEventListener('click', function(){

                           _this.instance.style.backgroundColor = _this.instance.style.backgroundColor == 'red' ? "blue" : "red" ;

                       });

                     }

                    function Points()

                    {

                       var _this = this;

                       this.container = [];

                       this.add = function(point)

                       {

                          _this.container.push(point); 

                       }

                       

                       this.run = function()

                       {

                           console.log('ssss');

                           var will_clicked_btns = []; 

                           for(var i = 0; i < 3; i++)

                           {

                               will_clicked_btns.push(parseInt(Math.random()*7));

                           }

                           for(var i = 0; i < will_clicked_btns.length; i++)

                           {

                               _this.container[will_clicked_btns[i]].click();

                           }

                       }

                    }

                    var points = new Points();

                    for(var i = 0; i < 8; i++)

                    {

                       var x = i *  + ; 

                       var p = new Point(x,0,,'red',"box");

                       p.render();

                       points.add(p);

                    }

                    setInterval(points.run, );

                })(); 

           </script>

       </html>

js for in 和 for of的区别

       for in是ES5标准,遍历key(属性名),并且原型链上的所有属性也会被遍历。过滤原型链上的属性可以用hasOwnProperty()方法。for in遍历后不能保证顺序(也就是顺序可能会被打乱)

        for of 是ES6标准,遍历value(属性值),这个方法修复for in存在的缺陷。

js的push方法

       For (var n=0;n<;n++)

       Info2.push(parseInt(Math.random()*)+1);

        //就是插入个1到之间的整数

更多内容请点击【百科】专栏