All net pen questions

First, a T-shaped pile up several FIG require repeated extending in all directions, it does not destroy the cell structure. (Required 12 minutes to complete.)

Then there is a pen questions 7 or 8, the front ends and two fill-divergent thinking, following this pen to write down questions or talking in small technology

1. Stack method ( last out )

var colors=new Array();
var count=colors.push('red','green');
alert(count);   //2
var item=colors.pop();
alert(item); //green
alert(colors.length); //1

   Method queue ( FIFO )

var Colors = new new the Array ();
 var COUNT = colors.unshift ( 'Red', 'Green' ); // enqueue - add array distal 
Alert (COUNT);    // 2 
var Item = colors.shift () ; // a team - delete the array front end 
Alert (Item);     // Red;

 

2. Use javascript to write any kind of sorting algorithms

   I used the selection sort

var arr=[3,9,5,4,2,8];
var temp;
for(var i=0;i<arr.length;i++){
     for(var j=i+1;j<arr.length;j++){
          if(arr[i]>arr[j]){
              temp=arr[i];
              arr[i]=arr[j];
              arr[j]=temp;      
          }
     }    
}
console.log(arr);   //[2,3,4,5,8,9] 

 

3. What is the css expression, as well as understanding and perception of css expressions? ?

    <style>
        body {
            background-color: expression((new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" );
        }
    </style>

Here you can use a special expression functions, in fact, this is a javascript function. It can be calculated according to an expression dynamically determining the background-color value.

It seems like a pretty nice feature, but we may not think this operation will expression many times (this specific number may be far more than you can imagine)

After opening, just moving around the mouse, or drag the scroll bar up and down several times, it will be executed 1865 times. As shown below

image

Obviously, this is a very significant number of costs. This is relatively simple expression, imagine if there is a more complex expression of it? These functions need to perform again and again, no doubt drag on performance efficiency of the implementation of the page, and even browser.

Because of this, not just the other browsers do not support, w3c standards organization does not support this approach. In view of this, Microsoft has also in 2008 (that time released IE 8) when formally terminated support for this function.

Three reasons are no longer supported CSS expressions mentioned in the text, is obviously very fair ( more standard, more conducive to enhance the performance and reduce the attack surface )

So if we really want to achieve dynamic CSS, how to do it? Such as the above example, we hope that based on the current time to determine what the background color. (Hours when one color is displayed in the singular, display a different color when plural).

  <script src="Scripts/jquery-2.0.0.min.js"></script>
    <script>
        $(function () {
            $("body").css("background-color", (new Date()).getHours() % 2 ? "#B8D4FF" : "#F08A00");
        });
    </script>

4. Write ie the bug, write at least five, and write solutions (content see "ie6 bug dwell" Documentation)

   1. Bilateral text overflow from 2.ie6 at 3.3 pixels 4.li blank line below the opaque problem 5.png

5. Each time returns a random value in the array

  Math.floor (Math.random () * + the length of the array of a number of possible)

6. inheritance

   Person has name, age properties. How to make Programmer class inherits name, age, sex, language

7. Write prepand, with the opposite appendChild

8. json a given string, the same output as the template sentence

9.

var num=100;
var obj={};
function sum(arg){
   age=20;
}
function other(obj){
    obj=20;
}
sum(num);
other(obj);
alert(num);    //100
alert(obj);    //object

10. From the browser, the code structure talk performance. And say what you are for web performance optimization.

11.jsonp difference principle, get ajax way, get in and post

12.javascript is single-threaded right? If this is how the single-threaded multi-threaded

13.javascript operating mechanism

 

 

Reproduced in: https: //www.cnblogs.com/positive/p/3620458.html

Guess you like

Origin blog.csdn.net/weixin_34357267/article/details/93495735