Ali 2015 questions

Source: Internet
Author: User

Analysis: JS has two types, the basic data type and the reference type, the array is the reference type, executes the second line is not only the assignment, Array2 also generated a pointer to Array1, that is array2 refers to array1, regardless of array1, array2 one of the changes, Two arrays will change, after the second line is executed array2 and array1 are equal to [up], after the third line is executed array1 and array2 are changed to [2,2], after the execution of line fourth, array1 and array2 are changed to [2,2,3]

Needless to say, the question of sending a sub-question, certainly no float

In fact, when doing the problem is not a special understanding, but still know that the concept of ' rearrangement ', refer to this article http://kb.cnblogs.com/page/169820/

when the reflow occurs:

    • Add or remove a visible DOM element
    • Change of element position
    • Element size Change
    • Content changes
    • Page Renderer Initialization
    • Changes in browser window size

This question tests the understanding of the prototype chain, if both itself and the prototype chain have defined a property name, then JS will first determine whether its own object has this property, and then return, not in the prototype chain to find, it is not found will return Underfind

PX Needless to say, is the relative length unit relative to the screen resolution

When using "Em" as a unit, it is important to know the setting of its parent element, because "em" is a relative value and a value relative to the parent element; is an indeterminate value, maybe 14px or 20px, depending on the value of the parent element

"em" is relative to its parent element to set the font size, so there is a problem, any element setting, it may be necessary to know the size of his parent element, when we use multiple times, will bring unpredictable error risk.

CSS3 introduced a new unit of measurement, Rem,rem is relative to the root element

Reference Address: Http://www.w3cplus.com/css3/define-font-size-with-css3-rem

Can also be written like this

1      functionisduplicate () {2         vararr =NewArray ();3              for(vari = 0;i<arguments.length;i++){4                 if(Arr.indexof (arguments[i]) = =-1){5 Arr.push (Arguments[i]);6                 }7             }8         if(arr.length<arguments.length) {9             return true;Ten}Else{ One             return false; A         } -}

The array is declared but not assigned, that is, there are no elements in the array, and if you have to write a arr[1], then arr will return Underfind, which means that the values in the array are actually declared Underfind

The wrong question: the problem is the closure and the immediate execution function

Analysis: First to analyze why the click of the mouse is the last ' p ' element discoloration? Debugging found in the Firebug in fact, the registration of the onclick is not executed every time, because the JS engine put it in the task queue at the end, and so on for the loop to execute, at this time to take the I is of course the last one; the workaround, write an immediate execute function (); But the function (j) was written in J, which was a bit confused ...

How to change: J To change the I,onclick function to the item to Document.getelementbytagname (' P ') [i] is OK,

Thinking: Because there is not much time, do not optimize, you should first get the DOM value to save and then use, you know the document every time to traverse the node, there is an efficiency problem

There was no time, then the problem did not do rough ...

1 functionRange () {2             vararr =NewArray ();3                 if(arguments.length==1){4                     if(Arguments[0] = = 0){5arr = [];6}Else{7arr = [Arguments[0]];8                     }9}Else if(arguments.length==2){Ten                      for(vari = arguments[0];i<arguments[1];i++){ One Arr.push (i); A                     } -}Else{ -                      for(vari = arguments[0];i<arguments[1];i+=arguments[2]){ the Arr.push (i); -                     } -                 } -                 returnarr; +}

Because the parameter is not sure, so I do not have to pass the argument, I directly use the arguments (argument copy)

But after writing a kind of pit daddy feeling ...

1 functionRandomarray () {2     varresult =NewArray ();3      while(true){4         varnum = parseint (math.random () *90+10);5         if(check (result,num) = =true){6 Result.push (num);7         }8         if(Result.length = = 10){9              Break;Ten         } One     } A     if(Result! =NULL){ -         returnResult.sort (function(A, B) {returnB-A}); -     }     the } -  - functionCheck (items,num) { -      for(vari = 0;i < items.length;i++){ +         if(Items[i] = =num) { -             return false; +         } A     } at     return true; -}

Ali question Bank questions are the basis of the comparison, my luck is better, pumping is relatively simple, even if all is JS problem, no HTML and CSS ...

Ali 2015 questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.