Front-end questions about JavaScript are you going to do that?

Source: Internet
Author: User
Tags tag name

Yesterday we shared a question about HTML and CSS , HTML and CSS for front-end questions, and today we share questions about JavaScript. I was most afraid of the interview when the interviewer asked me JS, because I really do not good at this. But I am in the study of hard work.

650) this.width=650; "class=" AlignCenter wp-image-1056 "src=" http://www.aliyue.net/wp-content/uploads/2016/06/ Msjs.jpg "alt=" Msjs "width=" height= "style=" Height:auto;vertical-align:middle;border:0px;text-align: center;margin:0px auto; "/>

The first time the baby interview than this is still tense!!!

1. Introduce the basic data type of JS

Undefined,Null,Boolean,number,String

What are the built-in objects for 2.js?

Data encapsulation Class object: Object, Array, Boolean, number, and String

Other objects: Function, Arguments, Math, Date, REGEXP, Error

understanding of 3.this objects

This always points to the direct caller of the function (not the indirect caller);

If there is a new keyword, this points to the new object;

In the event, this points to the object that triggered the event, and, in particular, the this in the attachevent in IE always points to the Global object window;

What does 4.eval do?

Its function is to parse the corresponding string into JS code and run;

You should avoid using eval, unsafe, very performance-consuming (2 times, parsing into JS statements at a time, executing once).

You can use Eval,var obj =eval (' (' + str + ') to convert a JSON string to a JSON object);

Note: Just now a group of small partners said that this writing has a performance loss to be as follows: Var obj=eval.call (this, ' (' +str+ ') '); A direct reference to eval causes all variables in the upper layer to be packaged into closures. (People have any ideas please feel free to leave me a message.) )

5.DOM How to add, remove, move, copy, create, and find nodes
Create a new node createdocumentfragment ()//Create a DOM fragment createelement ()//create a specific element createTextNode ()//Create a text node//Add, remove, replace, Insert AppendChild () removechild () ReplaceChild () insertbefore ()//Insert a new child node before the existing child node//Find getElementsByTagName ()// Through the tag name Getelementsbyname ()//through the value of the element's Name property (ie strong tolerance, will get an array, which includes the ID equals the name value of) getElementById ()//through element ID, uniqueness
What is the difference between 6.null and undefined?

Null is an object that represents "none", and a value of 0;undefined is a primitive value that represents "none", and a value of Nan when converted to a number.
Undefined

(1) The variable is declared, but when it is not assigned, it is equal to undefined.

(2) when calling a function, the argument that should be supplied is not provided, which equals undefined.

(3) The object does not have an assigned property, and the value of this property is undefined.

(4) When the function does not return a value, undefined is returned by default.
Null:

(1) As a function parameter, the parameter of the function is not an object.

(2) As the end point of the object prototype chain.

what exactly did the 7.new operator do ?

(1) An empty object is created, and the this variable references the object and also inherits the prototype of the function.

(2) The properties and methods are added to the object referenced by this.

(3) The newly created object is referenced by this and the last implicitly returns this.

8.JSON of understanding?

JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of JavaScript. Data format is simple, easy to read and write, occupy small bandwidth.

Format: Use key-value pairs, for example: {' age ': ' + ', ' name ': ' Back '}

9.call () and apply () The difference and role?

The Apply () function has two parameters: the first argument is the context, and the second parameter is an array of arguments. If the context is null, the global object is used instead.

such as: Function.apply (this,[1,2,3]);

The first parameter of call () is the context, followed by the sequence of arguments passed in by the instance.

such as: Function.call (this,1,2,3);

10. How do I get UA?
function Whatbrowser () {document.      Browser.name.value=navigator.appname; Document.      Browser.version.value=navigator.appversion; Document.      Browser.code.value=navigator.appcodename; Document.  Browser.agent.value=navigator.useragent; }

Tomorrow to update some of the more messy interview problems, or the old look, we have encountered any new interview questions to write to me! Let us more small partners not afraid of the interview. Abnormal interview questions will not, because some of the interviewer is really abnormal he will not take out!


This article is from the "Xiao Yue Blog" blog, please be sure to keep this source http://aliyue.blog.51cto.com/11564403/1792198

Front-end questions about JavaScript are you going to do that?

Related Article

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.