search
HomeWeb Front-endJS TutorialSummary of the latest front-end written test questions

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;
}

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>


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;";


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  src="/static/imghwm/default1.png"  data-src=""    style="max-width:90%"lazy"  id="portrait"  width="70"  style="max-width:90%" alt="Summary of the latest front-end written test questions" >
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);
  }
}

##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)

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;)

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)

十三、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!

Statement
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
Python vs. JavaScript: Performance and Efficiency ConsiderationsPython vs. JavaScript: Performance and Efficiency ConsiderationsApr 30, 2025 am 12:08 AM

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

The Origins of JavaScript: Exploring Its Implementation LanguageThe Origins of JavaScript: Exploring Its Implementation LanguageApr 29, 2025 am 12:51 AM

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

Behind the Scenes: What Language Powers JavaScript?Behind the Scenes: What Language Powers JavaScript?Apr 28, 2025 am 12:01 AM

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The Future of Python and JavaScript: Trends and PredictionsThe Future of Python and JavaScript: Trends and PredictionsApr 27, 2025 am 12:21 AM

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Python vs. JavaScript: Development Environments and ToolsPython vs. JavaScript: Development Environments and ToolsApr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Is JavaScript Written in C? Examining the EvidenceIs JavaScript Written in C? Examining the EvidenceApr 25, 2025 am 12:15 AM

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript's Role: Making the Web Interactive and DynamicJavaScript's Role: Making the Web Interactive and DynamicApr 24, 2025 am 12:12 AM

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C   and JavaScript: The Connection ExplainedC and JavaScript: The Connection ExplainedApr 23, 2025 am 12:07 AM

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor