国外一位程序员分享他关于面试前端程序员的思路,很有意思。
打开 Twitter 网站,查看源代码,要求面试者解释 Twitter 首页源代码的前 10 行,就是下面的这些代码:
同时,他提到这是一个开放性的问题,没有正确答案,只要面试者能回答出一些关键词,他会引导面试者到正确的方向上去,并且展开更深的讨论。
以此来考察面试者对于 HTML 等知识的了解情况。
同时对于每一行代码,他还给出来一个完美答案和可接受的答案,比如第一行
他给出的完美答案是:
This is the document type (doc-type) declaration that we always put as the first line in HTML files. You might think that this information is redundant because the browser already knows that the MIME type of the response is text/html; but in the Netscape/Internet Explorer days, browsers had the difficult task of figuring out which HTML standard to use to render the page from multiple competing versions.
This was especially annoying because each standard generated a different layout so this tag was adopted to make it easy for browsers. Previously, DOCTYPE tags were long and even included the specification link (kinda like SVGs have today), but luckily the simple <!doctype html> was standardized in HTML5 and still lives on.
\n
可以接受的答案是:
This is the DOCTYPE tag to let the browser know that this is an HTML5 page and should be rendered as such.
更多请查看原文: https://css-tricks.com/explain-the-first-10-lines-of-twitter-source-code/