Senior front-end Engineer Interview – 高級前端工程師面試準備知識清單

如果格式苛萎、圖片有問題谐丢,歡迎查看原文(可能會有更新馋吗、也歡迎交流):《Senior front-end Engineer Interview – 高級前端工程師面試準備知識清單

最近接到一個偏前端的面試通知,作為一個老司機缨叫,突然發(fā)現(xiàn)無從下手延届,前端不就是HTML + CSS + JS三件套嘛剪勿,好像什么都挺清楚的,但是深入一想祷愉,好像知識體系還是非常模糊的窗宦,這里特地整理下材料赦颇,希望對大家有幫助二鳄。

當(dāng)然我在海外,不知道適應(yīng)國內(nèi)的情況不媒怯。

一订讼、基礎(chǔ)知識

第一步,三件套大保缴劝(HTML + CSS + JS)的基礎(chǔ)知識需要過一遍欺殿,最好嘛從頭看一遍寄纵,找找自己哪些地方不是很清晰的,其實即便你做了很久的前端脖苏,很多基礎(chǔ)非常有可能依舊不是很清楚程拭。

看W3C或者我找到一個網(wǎng)站有知識的整理,還不錯:http://www.runoob.com/html/html-tutorial.html

以下是我找到的一些問題棍潘,復(fù)習(xí)完基礎(chǔ)之后恃鞋,可以試試。

Javascript

JS是前端唯一的亦歉,可以在面試中挖掘你水平的語言恤浪,所以需要非常深入的了解。以下幾個知識點可以用于自我檢測:

Execution context, especially lexical scope and closures.

Hoisting, function & block scoping and function expressions & declarations.

Binding – specifically call, bind, apply and lexical this.

Object prototypes, constructors and mixins.

Composition and high order functions.

Event delegation and bubbling.

Type Coercion using typeof, instanceof and Object.prototype.toString.

Handling asynchronous calls with callbacks, promises, await and async.

When to use function declarations and expressions.

What does the $ represent when using jQuery?

Explain the this keyword and it’s behaviour in JS.

What is the difference between the DOMContentLoaded and window.load events?

This This This!!!!

Prototype

DOM

這塊其實概念很簡單肴楷,但是很多時候我們用Jquery或者其他framework來處理水由,所以可能會非常不熟悉。

Selecting or finding nodes using document.querySelector and in older browsers document.getElementsByClassName.

Traversal up and down –?Node.parentNode,?Node.firstChild,?Node.lastChild?and?Node.childNodes.

Traversal left and right –?Node.previousSibling?and?Node.nextSibling.

Manipulation – add, remove, copy, and create nodes in the DOM tree. You should know operations such as how to change the text content of a node and toggle, remove or add a CSS classname.

Performance – touching the DOM can be expensive when you have many nodes, you should at least know about document fragments and node caching.

CSS

Layout – sitting elements next to each other and how to place elements in two columns vs three columns.

Knowledge demonstration questions and quizzes (Explain the box model, create a tooltip plugin, describe the different values of CSS position)

Responsive design – changing an element’s dimensions based on the browser width size.

Adaptive design – changing an element’s dimensions based on specific break points.

Specificity – how to calculate a selector’s specificity and how the cascade affects attributes.

Appropriate namespacing and naming of classnames.

What is the difference between display: block, display: inline and display: inline-block?

Explain the box-model and how it affects various CSS properties.

What is a normal HTTP request made up of?

What is BEM and explain why using something like it could be useful in your CSS?

position: relative, position: absolute and position: fixed

HTML

Semantic markup.

Tag attributes, such as disabled, async, defer and when to use data-*.

Knowing how to declare your doctype (most people are not writing new pages every day and forget this) and what meta tags are available to use.

Accessibility concerns, for example, making sure an input checkbox has a larger responding area (use label “for”). Also, role=”button”, role=”presentation”, etc.

二赛蔫、提高篇

作為senior的工程師砂客,光會大保健肯定不行,面試的時候還有cache呵恢,系統(tǒng)設(shè)計鞭盟,proformance優(yōu)化、算法等瑰剃。在這里整理下相關(guān)知識:

Critical rendering path.

Service workers.

Image optimizations.

Lazy loading and bundle splitting.

General implications of HTTP/2 and server-push.

When to prefetch and preload resources.

Reduce browser reflows and when to promote an element to the GPU.

Differences between the browser layout, compositing and painting.

HTTP requests – GET and POST along with associated headers such as Cache-Control, ETag, Status Codes, and Transfer-Encoding.

Meta questions – About source control, UI, HTTP & the web in general etc. See if the candidate knows a bit more beyond their specific topic of interest.

REST vs RPC.

Security – when to use JSONP, CORs, and iFrame policies.

CSS Preprocessing

Testing/Debug

Building and Automation Tools

Common cross browser issues and how to resolve them

CSS and JS minifying

三齿诉、資料推薦

對于this弄不清楚的,可以讀一讀這個:

https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&%20object%20prototypes/README.md#you-dont-know-js-this–object-prototypes

JS基礎(chǔ)梳理:這位朋友寫的非常棒晌姚,搜“JavaScript學(xué)習(xí)總結(jié)”:https://segmentfault.com/u/trigkit4/articles?page=5

四粤剧、筆記

這塊是我自己的筆記,只記錄了自己認為需要回看的東西

HTML

<base> 標簽描述了基本的鏈接地址/鏈接目標挥唠,該標簽作為HTML文檔中所有的鏈接標簽的默認鏈接

Block-Level, it takes whole line, <h1>, <p>, <ul>, <table>, <div>

inline, won’t change line, like <span>, <b>, <td>, <a>, <img>

只有在瀏覽器不支持腳本或者禁用腳本時抵恋,才會顯示 <noscript> 元素中的內(nèi)容

XHTML 是以 XML 格式編寫的嚴格更純凈的 HTML

HTML5: Canvas, SVG, MathML, Drag&Drop, Location, Video, Audio, input type, datalist

localStorage: 一直存在

sessionStorage: 關(guān)閉就clean

websocket

SSE – Server-sent event

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<div class=”container”><div class=”row” ><div class=”col-xs-6 col-sm-3″>

What is progressive rendering? – make page faster

Semantic tags are self-explanatory, <img>

CDN的版本控制:last-modified/etag控制,沒變化返回304宝磨,另外cache的控制是由expire/cafche-control

CSS

多重樣式優(yōu)先級: 內(nèi)聯(lián)樣式)Inline style > (內(nèi)部樣式)Internal style sheet >(外部樣式)External style sheet > 瀏覽器默認樣式

Box Modal:


inline element 不能設(shè)置高度弧关,寬度。從而理解了inline-block

相對定位唤锉,相對于元素的正常位置來進行定位世囊。元素在頁面占據(jù)位置×椋可以使用 top right bottom left 移動元素位置株憾。

絕對定位,相對于最近一級的 定位不是 static 的父元素來進行定位。元素在頁面不占據(jù)位置嗤瞎。 可以使用 top right bottom left 移動元素位置墙歪。

vendor-prefixed properties offered by the relevant rendering engines (-webkit for Chrome, Safari; -moz for Firefox, -o for Opera, -ms for Internet Explorer)

How do browsers read CSS? – From right to left.

pseudo-elements – list: first-child

Difference between standard/ strict mode and quirks mode? – quirks mode in browser allows u to render page for as old browsers. This is for backward compatibility.

JavaScript

document.getElementById(“demo”).innerHTML

局部變量會在函數(shù)運行以后被刪除。全局變量會在頁面關(guān)閉后被刪除

如果您把值賦給尚未聲明的變量贝奇,該變量將被自動作為全局變量聲明虹菲。如: carname=”Volvo”;

null和underfined:

typeof undefined ????????????// undefined

typeof null ?????????????????// object

null === undefined ??????????// false

null == undefined ???????????// true

5 種不同的數(shù)據(jù)類型:string, number, boolean, object, function

3 種對象類型:Object, Date, Array

2 個不包含任何值的數(shù)據(jù)類型:null, undefined

use strict

不允許使用未聲明的變量

不允許刪除變量或?qū)ο?/p>

不允許刪除函數(shù)

不允許變量重名

不允許對一個使用getter方法讀取的屬性進行賦值

變量名不能使用 “eval”, “arguments” 字符串

由于一些安全原因,在作用域 eval() 創(chuàng)建的變量不能被調(diào)用:

禁止this關(guān)鍵字指向全局對象掉瞳。

JavaScript處理常用的method

typeof()

Number(“3.2”)

toString()

indexOf()

substr()

charAt()

push() // to last

pop() // last one

shift() // remove first one

reverse()

addEventListener(“click”,function(){});

document.getElementById(“intro”);

document.getElementsByClassName(“intro”);

var myDate=new Date();

Math.round()

Math.random()

setInterval(function(){alert(“Hello”)},3000);

void: 該操作符指定要計算一個表達式但是不返回值届惋。

Hoisting: 是 JavaScript 默認將當(dāng)前作用域提升到前面去的的行為。使用表達式定義函數(shù)時無法提升菠赚。

arguments.length 屬性返回函數(shù)調(diào)用過程接收到的參數(shù)個數(shù):

function myFunction(a, b) {

???return arguments.length;

}


當(dāng)函數(shù)沒有被自身的對象調(diào)用時脑豹, this 的值就會變成全局對象。

JSON.parse() 方法將數(shù)據(jù)轉(zhuǎn)換為 JavaScript 對象

setTimeout/setInterval/匿名函數(shù)執(zhí)行的時候衡查,this默認指向window對象

Jquery常用method

attr()

append()

addClass()

css()

$(selector).load(URL,data,callback);

$.get(URL,callback);

$.post(URL,data,callback);

React 大體包含下面這些概念:

組件

JSX

Virtual DOM

Data Flow

JavaScript 是面向?qū)ο蟮恼Z言瘩欺,但 JavaScript 不使用類。 JavaScript 基于 [prototype][1]

apply拌牲、call 二者而言俱饿,作用完全一樣,只是接受參數(shù)的方式不太一樣塌忽。func.call(this, arg1, arg2);func.apply(this, [arg1, arg2])

How would you organize your Javascript code?

Break the code into logical units, keep them all in separate files

Use a script to concatenate/minify the files into a single bundle which you will serve as part of your app

Use JS namespaces to avoid cluttering up the global namespace

How can you add a method to a class already defined? – prototype

attribute vs property

<input?type=“checkbox”?checked=true/>

$(‘input’).prop(‘checked’);?// returns true

$(‘input’).attr(‘checked’);?// returns “checked”

If an element has a default value, the attribute shows the default value even if the value has changed.

<input type="text" name="username" value="user123">

$('input').prop('value', '456user');

$('input').prop('value'); // returns "456user"

$('input').attr('value'); // returns "user123"


Can you name two programming paradigms important for JavaScript app developers?

Prototypal inheritance (also: prototypes, OLOO).

Functional programming (also: closures, first class functions, lambdas).

What do you think of AMD vs CommonJS?

AMD is better for browser, hence, the name ‘Asynchronous’, as it loads each distinct module in async manner instead of loading in one large file. No extra steps are required to use AMD, it works out-of-the-box. In my opinion, as it is its in Asynchronous nature, it makes alot of async http requests and may not be as performant as described by other devs.

While, CommonJS, is a standard, mostly used in servers and it loads modules synchronously, though extra step is required if you want your JS file size to be minified and compressed.

How do you organize your code? – model pattern, create model with method

What’s the difference between host objects and native objects?

Native objects: Object (constructor), Date , Math , parseInt , eval , string methods like indexOf and replace , array methods, …

Host objects (assuming browser environment): window , document , location , history , XMLHttpRequest , setTimeout , getElementsByTagName , querySelectorAll

Describe event bubbling.

Event Bubbling 即指某個事件不僅會觸發(fā)當(dāng)前元素拍埠,還會以嵌套順序傳遞到父元素中。直觀而言就是對于某個子元素的點擊事件同樣會被父元素的點擊事件處理器捕獲土居。避免 Event Bubbling 的方式可以使用event.stopPropagation() 或者 IE 9 以下使用event.cancelBubble枣购。

Ternary expression: a>b? c:d

Promises:Promise 則是把類似的異步處理對象和處理規(guī)則進行規(guī)范化, 并按照采用統(tǒng)一的接口來編寫

Event Loop: 優(yōu)化JS單線程問題擦耀,就是在程序中設(shè)置兩個線程:一個負責(zé)程序本身的運行棉圈,稱為”主線程”;另一個負責(zé)主線程與其他進程(主要是各種I/O操作)的通信眷蜓,被稱為”Event Loop線程”(可以譯為”消息線程”)分瘾。

How would you compare two objects in JavaScript? – JSON.stringify()

a = (2, 3, 5); what is the value of a? – 5. The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.

Does JavaScript pass parameter by value or by reference? – Primitive type (string, number, etc.) are passed by value and objects are passed by reference.

JS中提供了一個DocumentFragment的機制,相信大家對這個并不陌生吁系,它可以提供一個緩沖的機制德召,將DOM節(jié)點先放到內(nèi)存中,當(dāng)節(jié)點都構(gòu)造完成后汽纤,再將DocumentFragment對象添加到頁面中上岗,這時所有的節(jié)點都會一次渲染出來,這樣就能減少瀏覽器很多的負擔(dān)冒版,明顯的提高頁面渲染速度

How could you prevent a click on an anchor from going to the link? – preventDefault()

Travel Nodes

parentNode

childNodes[nodenumber]

firstChild

lastChild

nextSibling

previousSibling

.firstChild.nodeValue;

message bus for applications, message queues is for users and applications


HTML5 – Server-sent event

var source=new EventSource("demo_sse.php");

source.onmessage=function(event)

{

???document.getElementById("result").innerHTML+=event.data + "<br>";

};

HTML5 – Web Worker

var w;

function startWorker() {

???if(typeof(Worker) !== "undefined") {

???????if(typeof(w) == "undefined") {

???????????w = new Worker("demo_workers.js");

???????}

???????w.onmessage = function(event) {

???????????document.getElementById("result").innerHTML = event.data;

???????};

???} else {

???????document.getElementById("result").innerHTML = "你的瀏覽器不支持 Web Workers...";

???}

}

function stopWorker()

{

???w.terminate();

???w = undefined;

}


HTML5 – WebStoarge

if (localStorage.clickcount)

{

???localStorage.clickcount=Number(localStorage.clickcount)+1;

}

else

{

???localStorage.clickcount=1;

}

document.getElementById("result").innerHTML=" 你已經(jīng)點擊了按鈕 " + localStorage.clickcount + " 次 ";

//保存數(shù)據(jù) ?

function save(){ ?

???var siteurl = document.getElementById("siteurl").value; ?

???var sitename = document.getElementById("sitename").value; ?

???localStorage.setItem(sitename, siteurl);

???alert("添加成功");

}

//查找數(shù)據(jù) ?

function find(){ ?

???var search_site = document.getElementById("search_site").value; ?

???var sitename = localStorage.getItem(search_site); ?

???var find_result = document.getElementById("find_result"); ?

???find_result.innerHTML = search_site + "的網(wǎng)址是:" + sitename; ?

}

Use Strict下的this

function f(){

return !this;

}

// 返回false液茎,因為"this"指向全局對象,"!this"就是false

function f(){

"use strict";

return !this;

}

// 返回true辞嗡,因為嚴格模式下捆等,this的值為undefined,所以"!this"為true续室。


Jquery Load

$("button").click(function(){

?$("#div1").load("demo_test.txt",function(responseTxt,statusTxt,xhr){

???if(statusTxt=="success")

?????alert("外部內(nèi)容加載成功!");

???if(statusTxt=="error")

?????alert("Error: "+xhr.status+": "+xhr.statusText);

?});

});


Jquery Post

$("button").click(function(){

???$.post("/try/ajax/demo_test_post.php",

???{

???????name:"菜鳥教程",

???????url:"http://www.runoob.com"

???},

???????function(data,status){

???????alert("數(shù)據(jù): \n" + data + "\n狀態(tài): " + status);

???});

});


Scope and hoisting

var a = 1;

function b() {

???a = 10;

???return;

???function a() {}

}

b();

console.log(a);


Explanation:

function declaration function a(){} is hoisted first and it behaves like var a = function () {};. Hence in local scope variable a is created.

If you have two variables with same name (one in global another in local), local variable always get precedence over global variable.

When you set a = 10;, you are setting the local variable a , not the global one. Hence, the value of global variable remain same and you get, 1 in the log. ref: js hoisting/scope

Extra: If you didnt have a function named as “a”, you will see 10 in the log.

Append Class

var li = document.createElement("li");

var text = document.createTextNode('Only one Item');

li.appendChild(text);


遍歷頁面所有元素

var all = document.getElementsByTagName("*");

for (var i=0, max=all.length; i < max; i++) {

????console.log(all[i]);

}

遍歷子節(jié)點

var usernameEle = document.getElementById("center");

?var childs = usernameEle.childNodes; ?

?for(var i = childs.length - 1; i >= 0; i--) { ?????

?????console.log(childs[i]); ?????

?}


參考文章:

https://www.linkedin.com/pulse/preparing-front-end-web-development-interview-2017-david-shariff

https://ashleynolan.co.uk/blog/a-guide-to-front-end-interviews

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末栋烤,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子挺狰,更是在濱河造成了極大的恐慌明郭,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,743評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件丰泊,死亡現(xiàn)場離奇詭異薯定,居然都是意外死亡,警方通過查閱死者的電腦和手機瞳购,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,296評論 3 385
  • 文/潘曉璐 我一進店門话侄,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人学赛,你說我怎么就攤上這事年堆。” “怎么了盏浇?”我有些...
    開封第一講書人閱讀 157,285評論 0 348
  • 文/不壞的土叔 我叫張陵变丧,是天一觀的道長。 經(jīng)常有香客問我绢掰,道長痒蓬,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,485評論 1 283
  • 正文 為了忘掉前任滴劲,我火速辦了婚禮谊却,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘哑芹。我一直安慰自己炎辨,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 65,581評論 6 386
  • 文/花漫 我一把揭開白布聪姿。 她就那樣靜靜地躺著碴萧,像睡著了一般。 火紅的嫁衣襯著肌膚如雪末购。 梳的紋絲不亂的頭發(fā)上破喻,一...
    開封第一講書人閱讀 49,821評論 1 290
  • 那天,我揣著相機與錄音盟榴,去河邊找鬼曹质。 笑死,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的羽德。 我是一名探鬼主播几莽,決...
    沈念sama閱讀 38,960評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼宅静!你這毒婦竟也來了章蚣?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,719評論 0 266
  • 序言:老撾萬榮一對情侶失蹤姨夹,失蹤者是張志新(化名)和其女友劉穎纤垂,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體磷账,經(jīng)...
    沈念sama閱讀 44,186評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡峭沦,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,516評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了逃糟。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片吼鱼。...
    茶點故事閱讀 38,650評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖履磨,靈堂內(nèi)的尸體忽然破棺而出蛉抓,到底是詐尸還是另有隱情,我是刑警寧澤剃诅,帶...
    沈念sama閱讀 34,329評論 4 330
  • 正文 年R本政府宣布巷送,位于F島的核電站,受9級特大地震影響矛辕,放射性物質(zhì)發(fā)生泄漏笑跛。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,936評論 3 313
  • 文/蒙蒙 一聊品、第九天 我趴在偏房一處隱蔽的房頂上張望飞蹂。 院中可真熱鬧,春花似錦翻屈、人聲如沸陈哑。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,757評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽惊窖。三九已至,卻和暖如春厘贼,著一層夾襖步出監(jiān)牢的瞬間界酒,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,991評論 1 266
  • 我被黑心中介騙來泰國打工嘴秸, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留毁欣,地道東北人庇谆。 一個月前我還...
    沈念sama閱讀 46,370評論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像凭疮,于是被迫代替她去往敵國和親饭耳。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,527評論 2 349

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,309評論 0 10
  • The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...
    網(wǎng)事_79a3閱讀 11,941評論 3 20
  • (本文參加#感悟三下鄉(xiāng),青春筑夢行#活動耕姊,本人承諾桶唐,文章內(nèi)容為原創(chuàng),且未在其他平臺發(fā)表過茉兰。) 送孩子回家和第一次家...
    大陳1000閱讀 328評論 4 2
  • 今天有什么都沒做尤泽,心情很差,不知為什么晚上情緒失控规脸,整個人很窩火的感覺坯约,下了一個舒伯特表格,以后多練習(xí)練習(xí)莫鸭,希望有...
    兆之閱讀 186評論 0 0
  • 運行命令 killall -9 node 運行命令 npm start 如果是在使用ios模擬器運行react-n...
    Albert新榮閱讀 806評論 0 0