Baidu Front-End written interview 7 questions

Source: Internet
Author: User
Tags format current time functions include reference setinterval advantage linux

1. What data types does JavaScript include?

I'm responding to two types: basic types and objects, with basic types including numbers, strings, Boolean, and null, objects (like objects), including arrays, functions, built-in objects, and custom objects. But logically, strings are also characteristic of some objects.

My answer is a reference to the JavaScript Authority guide, with some minor problems in the first category lacking undefined.

After searching, there are several answers on the Web:

First: total nine types: 1. Not defined (undefined) 2. Null (NULL) 3 Boolean (Boolean) 4. String (String) 5. Number 6. Object (object) 7. Reference (Reference) 8. Listing (list) 9. Complete (completion). Reference,list,completion These 3 types are data types that are intermediate results for JavaScript runtime and cannot be used in code.

I did not see it at last.

The second type:JavaScript contains 6 types of data: Undefined, NULL, string, number, Boolean, and object. Of these, the first 5 are the original data types, and object is the type. Object types include object, Function, String, number, Boolean, Array, Regexp, Date, Globel, Math, Error, and object types provided by the hosting environment.

Apart from the reference,list,completion, these answers are very similar in number.

2, elements of Alt and title what similarities and differences?

I just saw an article like this a few days ago. These two properties are somewhat repetitive. There are some differences in different browsers. When Alt and title are set at the same time, Alt appears as the alternate text for the picture, and title is the explanatory text of the picture.

Just a little experiment, in the absence of title, Alt will be interpreted as a picture, but Firefox does not seem to do so. Complete test words to be divided into the picture exists, only title, only alt,2*2*2,8 kind of situation, really complicated ah.

3, Border-color-left, Marin-left,-moz-viewport rewrite into javascript format

This is-after the character is capitalized, no problem. The third-moz is really not sure. (To be continued)

PS: Just received the phone call Baidu interview, wait for a long time, think that there is no hope, a little happy. However, I do not have much advantage, whether it is technical or experience, only disadvantages have no advantage, but the RP is OK (secretly pleased). The written test passed some luck, to Baidu's hope is not big.

Continuation: Just tested a-moz-border-radius is really written in Mozborderradius.

4, write a JavaScript function, real-time display of the current time, format "year-month-day: minutes: Seconds"

The main use of a variety of time functions, SetInterval (Funtionname,time), Firstchild.nodevalue.

setinterval function name I seem to have written it wrong. I write the most common and simplest function, which is to retrieve time every second. There are plenty of places to optimize. The program does not write well, it is not shortcoming.

5, with CSS, html to write a two-column layout of the Web page, asking the right width of 200px, automatic extension to the left.

My main idea is the right side of the absolute positioning, left box right away from 200px, just vacated the right side of the position.

I wrote the following CSS:

#right{
  position:absolute;
   right:0;
   width:200px;
}
#left{
  marin-right:200px;
}

Another method (test effective):

#right{
  float:right;
  width:200px;
}
#left{
  marin-right:200px;
}

#right in HTML code must be written in front of #left

<body>
  <div id=”right”>…</div>
  <div id=”left”>…</div>
</body>

It's like a classic interview question that was asked in a certain interview. Another classic question is how to make a fixed-width div centered on the page.

6. Use JavaScript depth to clone an object?

The JavaScript object assignment var anobj = Anotherobj is used for the address method and cannot be used for copying objects.

Using object prototypes to write more general versatility, but at the time did not quite grasp the prototype, only wrote a cloning function. Just checked the next, there is something fishy, the following is the implementation code:

function Object.prototype.cloneObj()
{
   function NEWOBJECT(){};
   NEWOBJECT. prototype = this;
   var anObj = new NEWOBJECT();
   for ( var ele in anObj )
   {
      if ( typeof anObj[ele] == “object” ) return anObj[ele]. cloneObj();
   }
   return anObj;
}

7.Linux title: Bulk Delete files in the current directory with a suffix named. C, such as A.C, B.C

My answer is RM *.c.

Fortunately, I still have a little bit of Linux basis, of course, thanks to review several common Linux commands before the exam.

The additional question is the flash as the question, probably is compares AS2.0 and AS3.0 in the object-oriented aspect similarities and differences. I have not contacted as for a long time, this problem I did not answer.



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.