Home > Web Front-end > JS Tutorial > Summary of the latest front-end written test questions

Summary of the latest front-end written test questions

php中世界最好的语言
Release: 2017-11-18 16:59:08
Original
2095 people have browsed it

Seeing that many friends are asking for front-end written test questions, I collected some interview questions for you. These are all the latest questions in 2017. I hope they will help you improve your skills. I also wish you can get into the company you want to work in.

This article collects and analyzes the latest 2017 front-end written test questions in more detail. Share it with everyone for your reference. The details are as follows:

1. Two divs on a page cover the entire browser. Make sure that the left div is always 100px, and the right div changes with the size of the browser (for example, the browser is 500, and the right div is 400, the browser is 900, and the div on the right is 800), please write down the approximate css code.

1. Use flex

//html
<div class=&#39;box&#39;><div class=&#39;left&#39;></div> <div class=&#39;right&#39;></div></div>
//css
.box {
    width: 400px;
    height: 100px;
    display: flex;
    flex-direction: row;
    align-items: center;
    border: 1px solid #c3c3c3;
}
.left {
    flex-basis:100px;
    -webkit-flex-basis: 100px;
    /* Safari 6.1+ */
    background-color: red;
    height: 100%;
}
.right {
    background-color: blue;
    flex-grow: 1;
}
Copy after login

2. Floating layout

<div id="left">Left sidebar</div>
<div id="content">Main Content</div>
<style type="text/css">
* {
    margin: 0;
    padding: 0;
}
#left {
    float: left;
    width: 220px;
    background-color: green;
}
#content {
    background-color: orange;
    margin-left: 220px;
    /*==等于左边栏宽度==*/
}
</style>
Copy after login


2. Please write down some front-end performance optimization methods, the better The more the better


1. Reduce DOM operations

2. Before deployment, image compression, code compression

3. Optimize js code Structure, reduce redundant code

4. Reduce http requests, set HTTP cache appropriately

5. Use content distribution cdn to accelerate

6. Static resource caching

7. Delayed loading of images


3. What happens in the process from inputting the URL to the completion of page loading and display of a page? (The more detailed the process, the better)


Enter the address

1. The browser searches for the IP address of the domain name

2.This One step includes the specific search process of DNS, including: browser cache->system cache->router cache...

3. The browser sends an HTTP request to the web server

4. Server Permanent redirect response (from http://example.com to http://www.example.com)

5. The browser tracks the redirect address

6. The server processes the request

7. The server returns an HTTP response

8. The browser displays HTML

9. The browser sends a request to obtain resources embedded in HTML (such as pictures, audio, Video, CSS, JS, etc.)

10. The browser sends an asynchronous request


4. Please briefly describe the restrictions on page access cookies


Cross-domain issues

Set HttpOnly


5. Describe browser redraw and reflow, What methods can improve the reflow caused by dom operations


1. Change the className directly. If you change the style dynamically, use cssText

// 不好的写法
var left = 1;
var top = 1;
el.style.left = left + "px";
el.style.top = top + "px"; // 比较好的写法
el.className += " className1";
// 比较好的写法
el.style.cssText += ";
left: " + left + "px;
top: " + top + "px;";
Copy after login


2. Let the elements to be operated be "offline processed" and update them together after processing


a) Use DocumentFragment to perform caching operations, triggering a reflow and Redraw;

b) Use display:none technology to trigger only two reflows and redraws;

c) Use cloneNode(true or false) and replaceChild technology to trigger one reflow and redraw Draw


Six, vue life cycle hook


##1.beforcreate

2.created

3.beformount

4.mounted

5.beforeUpdate

6.updated

7.actived

8.deatived

9.beforeDestroy

10.destroyed


7. How many methods can be written for js cross-domain requests? Several


##1. Cross domain through jsonp

2. Cross subdomain by modifying document.domain

3. Use window .name for cross-domain

4. Use the newly introduced window.postMessage method in HTML5 to transmit data across domains (ie 67 does not support it)

5. CORS requires the server to set the header: Access -Control-Allow-Origin.

6. This method of nginx reverse proxy is rarely mentioned, but it does not require the cooperation of the target server, but you need to build a transit nginx server to forward requests


8. Understanding of front-end engineering


Development specifications

Modular development

Component development

Component Warehouse

Performance Optimization

Project Deployment

Development Process

Development Tools


Nine, js deep copy method


1. Use jq’s $.extend(true, target, obj)

2. newobj = Object.create(sourceObj), // But there is a problem with this. Changes to newobj will not affect sourceobj, but changes to sourceobj will affect newObj

3.newobj = JSON.parse(JSON. stringify(sourceObj))


10. js design patterns


Generally speaking, design patterns are divided into three categories :

There are five creative patterns: factory method pattern,

Abstract factory pattern

, singleton pattern, builder pattern, and prototype pattern. There are seven structural modes:

Adapter mode

, Decorator mode, Agent mode, Appearance mode, Bridge mode, Combination mode, Flyweight mode. Behavioral patterns, eleven types in total: strategy pattern, template method pattern,

Observer pattern

, iterative sub pattern, Chain of responsibility pattern, command pattern, memo Mode, state mode, visitor mode, mediator mode


11. Picture preview

<input type="file" name="file" onchange="showPreview(this)" />
<img id="portrait" src="" width="70" height="75">
function showPreview(source) {
  var file = source.files[0];
  if(window.FileReader) {
      var fr = new FileReader();
      fr.onloadend = function(e) {
        document.getElementById("portrait").src = e.target.result;
      };
      fr.readAsDataURL(file);
  }
}
Copy after login

##12 , Flattened multi-dimensional array

1, Old method

var result = []
function unfold(arr){
     for(var i=0;i< arr.length;i++){
      if(typeof arr[i]=="object" && arr[i].length>1) {
       unfold(arr[i]);
     } else {        
       result.push(arr[i]);
     }
  }
}
var arr = [1,3,4,5,[6,[0,1,5],9],[2,5,[1,5]],[5]];
unfold(arr)
Copy after login

2、使用tostring

var c=[1,3,4,5,[6,[0,1,5],9],[2,5,[1,5]],[5]];
var b = c.toString().split(&#39;,&#39;)
Copy after login

3、使用es6的reduce函数

var arr=[1,3,4,5,[6,[0,1,5],9],[2,5,[1,5]],[5]];
const flatten = arr => arr.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
var result = flatten(arr)
Copy after login

十三、iframe有那些缺点?

iframe会阻塞主页面的Onload事件;

搜索引擎的检索程序无法解读这种页面,不利于SEO;

iframe和主页面共享连接池,而浏览器对相同域的连接有限制,所以会影响页面的并行加载。

使用iframe之前需要考虑这两个缺点。如果需要使用iframe,最好是通过javascript动态给iframe添加src属性值,这样可以绕开以上两个问题。


以上就是我收集的前端笔试题以及答案,所述对大家有所帮助。

推荐阅读:

作为前端开发工程师一定要关注三点的性能指标

前端JS面试题

php学习之为什么说PHP适合做前端JAVA适合做后端?

The above is the detailed content of Summary of the latest front-end written test questions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template