avaScript Charts兼容性好的JavaScript、HTML5圖表開發(fā)工具,能滿足大部分的開發(fā)需求,包括序列圖表(列型圖,條形圖,線型圖,面積圖,步驟折線圖,平滑折線圖,蠟燭圖,ohlc圖),餅圖/環(huán)形圖,雷 達(dá)圖/極區(qū)圖以及xy圖/散點圖/氣泡圖。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯
7. 頁面 社會化 分享功能
8. 富文本編輯器
9. 日歷
10. 綜合效果搜索平臺
11. 前端工程化
12. 輪播圖
- [無縫切換](http://www.swipejs.com/)
- [滑屏效果](http://www.idangero.us/swiper/)
- [全屏fullpage](https://github.com/peunzhang/fullpage)
- [單個圖片切換](https://github.com/qiqiboy/touchslider)
- [單個全屏切換](https://github.com/peunzhang/slip.js)
- [百度的切換庫](http://touch.code.baidu.com/examples.html?qq-pf-to=pcqq.group)
- [單個全屏切換](https://github.com/peunzhang/iSlider)
- [滑屏效果](https://github.com/saw/touch-interfaces)
- [旋轉(zhuǎn)拖動設(shè)置](http://baijs.com/tinycircleslider/)
- [類似于swipe切換](http://touchslider.com/)
- [支持多種形式的觸摸滑動](http://www.swiper.com.cn/demo/index.html)
- [滑屏效果](https://github.com/joker-ye/main/blob/master/wap/index.html)
- [大話主席pc移動圖片輪換](http://www.superslide2.com/)
- [滑屏效果](https://github.com/hahnzhu/parallax.js)
- [基于zepto的fullpage](https://github.com/yanhaijing/zepto.fullpage)
- [ - 定寬網(wǎng)頁設(shè)計下,固定寬度布局開發(fā)WebApp并實現(xiàn)多終端下WebApp布局自適應(yīng)](http://www.cnblogs.com/plums/archive/2013/01/10/WebApp-fixed-width-layout-of-multi-terminal-adapter-since.html][WebApp)
- [判斷微信客戶端的那些坑](http://loo2k.com/blog/detecting-wechat-client/)
- [可以通過javascript直接調(diào)用原生分享的工具](https://github.com/JefferyWang/nativeShare.js)
- [JiaThis 分享到微信代碼](http://www.jiathis.com/help/html/weixin-share-code)
- [聊聊移動端跨平臺開發(fā)的各種技術(shù)](http://fex.baidu.com/blog/2015/05/cross-mobile/)
- [前端自動化測試](http://www.zhihu.com/question/29922082)
- [多種輪換圖片](http://ajccom.github.io/niceslider/)
- [滑動側(cè)邊欄](https://mango.github.io/slideout/)
13. 文件上傳
14. 模擬select
15. 取色插件
16. 城市聯(lián)動
17. 剪貼板
18. 簡繁轉(zhuǎn)換
19. 表格 Grid
20. 在線演示
21. 播放器
22. 粒子動畫
九. Nodejs
十. 性能優(yōu)化
- [Javascript高性能動畫與頁面渲染](http://www.infoq.com/cn/articles/javascript-high-performance-animation-and-page-rendering)
- [移動H5前端性能優(yōu)化指南](http://isux.tencent.com/h5-performance.html)
- [5173首頁前端性能優(yōu)化實踐](http://ued.5173.com/?p=1731)
- [給網(wǎng)頁設(shè)計師和前端開發(fā)者看的前端性能優(yōu)化](http://www.uisdc.com/front-end-performance-for-web-designers-and-front-end-developers)
- [復(fù)雜應(yīng)用的 CSS 性能分析和優(yōu)化建議](http://www.orzpoint.com/profiling-css-and-optimization-notes/)
- [張鑫旭——前端性能](http://www.zhangxinxu.com/wordpress/tag/%E5%89%8D%E7%AB%AF%E6%80%A7%E8%83%BD/)
- [前端性能監(jiān)控總結(jié)](http://www.xiaoqiang.org/javascript/font-end-performance-monitor.html)
- [ 網(wǎng)站性能優(yōu)化之CSS無圖片技術(shù)](http://udc.weibo.com/2013/05/%E7%BD%91%E7%AB%99%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E4%B9%8Bcss%E6%97%A0%E5%9B%BE%E7%89%87%E6%8A%80%E6%9C%AF/)
- [web前端性能優(yōu)化進(jìn)階路](http://www.aliued.cn/2013/01/20/web%E5%89%8D%E7%AB%AF%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E8%BF%9B%E9%98%B6%E8%B7%AF.html)
- [前端技術(shù):網(wǎng)站性能優(yōu)化之CSS無圖片技術(shù)](http://my.eoe.cn/tuwandou/archive/4544.html)
- [瀏覽器的加載與頁面性能優(yōu)化](http://www.baiduux.com/blog/2011/02/15/browser-loading/)
- [頁面加載中的圖片性能優(yōu)化](http://www.w3ctech.com/p/1503)
- [Hey——前端性能](http://www.feelcss.com/tag/%E5%89%8D%E7%AB%AF%E6%80%A7%E8%83%BD)
- [html優(yōu)化](http://www.baiduux.com/blog/2010/03/15/html%E4%BC%98%E5%8C%96-2/)
- [99css——性能](http://www.99css.com/tag/%e6%80%a7%e8%83%bd)
- [Yslow——性能優(yōu)化](http://www.yslow.net/category.php?cid=20)
- [YSLOW中文介紹](http://www.cnblogs.com/yslow/)
- [轉(zhuǎn)一篇Yahoo關(guān)于網(wǎng)站性能優(yōu)化的文章,兼談本站要做的優(yōu)化](http://www.360ito.com/article/40.html)
- [Yahoo!團(tuán)隊實踐分享:網(wǎng)站性能](http://www.360doc.com/content/10/0928/09/2588264_56971287.shtml)
- [網(wǎng)站性能優(yōu)化指南:什么使我們的網(wǎng)站變慢?](http://blog.jiasule.com/i/153)
- [網(wǎng)站性能優(yōu)化實踐,減少加載時間,提高用戶體驗](http://www.powereasy.net/helpyou/knowledge/ecommerce/9593.html)
- [淺談網(wǎng)站性能優(yōu)化 前端篇](http://www.umtry.com/archives/747.html)
- [前端重構(gòu)實踐之如何對網(wǎng)站性能優(yōu)化?](http://www.adinnet.cn/blog/designview/2012-7-12/678.html)
- [前端性能優(yōu)化:使用媒體查詢加載指定大小的背景圖片](http://www.gbin1.com/technology/javascript/20130708-front-end-performance-optimization-9/)
- [網(wǎng)站性能系列博文](http://www.mykuer.com/post/factors-that-affect-the-speed-of-web-site-open.html)
- [加載,不只是少一點點](http://tgideas.qq.com/webplat/info/news_version3/804/808/811/m579/201109/41355.shtml)
- [前端性能的測試與優(yōu)化](http://mzhou.me/article/95310/)
- [分享網(wǎng)頁加載速度優(yōu)化的一些技巧?](http://www.gbin1.com/technology/html/20130217-tips-for-speed-up-page-loading/)
- [頁面加載中的圖片性能優(yōu)化](http://www.f2es.com/images-bytes-opt/)
- [web前端優(yōu)化(基于Yslow)](http://www.tcreator.info/webSchool/website/Front-end-Opt-Yslow.html)
- [網(wǎng)站性能優(yōu)化工具大全](https://www.qianduan.net/website-performance-optimization-tool.html)
- [【高性能前端1】高性能HTML](http://www.alloyteam.com/2012/10/high-performance-html/)
- [【高性能前端2】高性能CSS](http://www.alloyteam.com/2012/10/high-performance-css/)
- [由12306談?wù)劸W(wǎng)站前端性能和后端性能優(yōu)化](http://coolshell.cn/articles/6470.html)
- [AlloyTeam——前端優(yōu)化](http://www.alloyteam.com/webfrontend/%E5%89%8D%E7%AB%AF%E4%BC%98%E5%8C%96/)
- [毫秒必爭,前端網(wǎng)頁性能最佳實踐](http://www.cnblogs.com/developersupport/p/3248695.html)
- [網(wǎng)站性能工具Yslow的使用方法](http://blog.sina.com.cn/s/blog_6e9d2e0701017kvu.html)
- [前端工程與性能優(yōu)化(上):靜態(tài)資源版本更新與緩存](http://www.infoq.com/cn/articles/front-end-engineering-and-performance-optimization-part1)
- [前端工程與性能優(yōu)化(下):靜態(tài)資源管理與模板框架](http://www.infoq.com/cn/articles/front-end-engineering-and-performance-optimization-part2)
- [HTTPS連接的前幾毫秒發(fā)生了什么](http://blog.jobbole.com/48369/)
- [Yslow](http://uicss.cn/yslow/#more-12319)
- [Essential Web Performance Metrics — A Primer, Part 1](http://blog.smartbear.com/web-performance/essential-web-performance-metrics-a-primer-part-1/)
- [Essential Web Performance Metrics — Part 2](http://blog.smartbear.com/performance/essential-web-performance-metrics-part-2/)
- [YUISlide,針對移動設(shè)備的動畫性能優(yōu)化](http://jayli.github.io/blog/data/2011/12/23/yuislide.html)
- [Improving Site Performance](http://joelglovier.com/improving-site-performance/)
- [讓網(wǎng)站提速的最佳前端實踐](http://segmentfault.com/a/1190000000367899)
- [Why Website Speed is Important](http://sixrevisions.com/web-development/why-website-speed-is-important/)
- [Need for Speed – How to Improve your Website Performance](https://www.devbridge.com/articles/need-for-speed-how-to-improve-your-website-performance/)
- [阿里無線前端性能優(yōu)化指南 (Pt.1 加載期優(yōu)化)](https://github.com/amfe/article/issues/1)
十一. 前端架構(gòu)
十二. 個人作品
1. 推薦作品
2. 群員作品
3. 國外大牛精品
十三. 簡歷模板
十四. 面試題
十五. iconfont
十六. 開發(fā)工具類
十七. 前端導(dǎo)航網(wǎng)站
十八. 常用CDN
十九. Git,SVN,Github
這些技術(shù)如何學(xué)習(xí),有沒有免費資料?
對前端的技術(shù),架構(gòu)技術(shù)感興趣的同學(xué)關(guān)注我的頭條號,并在后臺私信發(fā)送關(guān)鍵字:“前端”即可獲取免費的架構(gòu)師學(xué)習(xí)資料
源|https://segmentfault.com/a/1190000015288700
本篇文章整理總結(jié)了一些前端面試題,涵蓋面很廣,并且面的都是知名大廠,所以這些題還是很有代表性的,都掌握以后一面基礎(chǔ)面應(yīng)該沒什么問題,二面也能應(yīng)付大半,奉上:
1. 萬能居中
1.margin: 0 auto;水平
2.text-align: center;水平
3.行高,垂直
4.表格,center,middle;水平垂直
5.display:table-cell;模擬表格,all
6.絕對定位,50%減自身寬高
7.絕對定位,上下左右全0,margin:auto
8.絕對定位加相對定位。不需要知道寬高
9.IE6,IE7:給父元素設(shè)一個font-size:高度/1.14,vertical-align:middle
2. BFC優(yōu)化
塊格式化上下文, 特性:
3. 和模型哪兩種模式?什么區(qū)別?如何設(shè)置
4. 常用清除浮動的方法,如不清除浮動會怎樣?
當(dāng)父元素不給高度的時候,內(nèi)部元素不浮動時會撐開, 而浮動的時候,父元素變成一條線, 造成塌陷.
5. 柵格化的原理
比如antd的row和col, 將一行等分為24份, col是幾就占幾份, 底層按百分比實現(xiàn); 結(jié)合媒體查詢, 可以實現(xiàn)響應(yīng)式
6. 純css實現(xiàn)三角形
// 通過設(shè)置border
.box
{
width:0px;
height:0px;
border-top:50px solid rgba(0,0,0,0);
border-right:50px solid rgba(0,0,0,0);
border-bottom:50px solid green;
border-left:50px solid rgba(0,0,0,0);
}
7. 高度不定,寬100%,內(nèi)一p高不確定,如何實現(xiàn)垂直居中?
8. 至少兩種方式實現(xiàn)自適應(yīng)搜索
9. 設(shè)置一段文字的大小為6px
10. css菊花圖
四個小圓點一直旋轉(zhuǎn)
// 父標(biāo)簽
animation: antRotate 1.2s infinite linear;
// 子標(biāo)簽
animation: antSpin 1s infinite linear;
@keyframe antSpin {
to {
opacity: 1
}
}
@keyframe antRotate {
to {
transform: rotate(405)
}
}
// animation-delay: 逐個延遲0.4s
11. 關(guān)于em
<p style="font-size: 20px">
123
<p style="font-size: 2em;width: 2em">456</p>
</p>
// 此時子元素的font-size為40px, 寬度為80px(還要乘以子元素font-size的系數(shù))
12. 關(guān)于vh, vw
vw:viewpoint width,視窗寬度,1vw等于視窗寬度的1%。
vh:viewpoint height,視窗高度,1vh等于視窗高度的1%。
vmin:vw和vh中較小的那個。
vmax:vw和vh中較大的那個。
13. Flex布局
14. overflow原理
15. 實現(xiàn)自適應(yīng)的正方形:
16. 標(biāo)準(zhǔn)模式和怪異模式
17. CSS3實現(xiàn)環(huán)形進(jìn)度條
兩個對半矩形遮罩, 使用rotate以及overflow: hidden進(jìn)行旋轉(zhuǎn)
18. css優(yōu)先級
選擇器的特殊性值表述為4個部分,用0,0,0,0表示。
1. ES5和ES6繼承方式區(qū)別
2. Generator了解
ES6 提供的一種異步編程解決方案, Generator 函數(shù)是一個狀態(tài)機(jī),封裝了多個內(nèi)部狀態(tài)。
// 通過設(shè)置border.box { width:0px; height:0px; border-top:50px solid rgba(0,0,0,0); border-right:50px solid rgba(0,0,0,0); border-bottom:50px solid green; border-left:50px solid rgba(0,0,0,0); }
調(diào)用后返回指向內(nèi)部狀態(tài)的指針, 調(diào)用next()才會移向下一個狀態(tài), 參數(shù):
hw.next()
// { value: 'hello', done: false }
hw.next()
// { value: 'world', done: false }
hw.next()
// { value: 'ending', done: true }
hw.next()
// { value: undefined, done: true }
3. 手寫Promise實現(xiàn)
var myPromise=new Promise((resolve, reject)=> {
// 需要執(zhí)行的代碼
...
if (/* 異步執(zhí)行成功 */) {
resolve(value)
} else if (/* 異步執(zhí)行失敗 */) {
reject(error)
}
})
myPromise.then((value)=> {
// 成功后調(diào)用, 使用value值
}, (error)=> {
// 失敗后調(diào)用, 獲取錯誤信息error
})
4. Promise優(yōu)缺點
function promise () {
this.msg='' // 存放value和error
this.status='pending'
var that=this
var process=arguments[0]
process (function () {
that.status='fulfilled'
that.msg=arguments[0]
}, function () {
that.status='rejected'
that.msg=arguments[0]
})
return this
}
promise.prototype.then=function () {
if (this.status==='fulfilled') {
arguments[0](this.msg)
} else if (this.status==='rejected' && arguments[1]) {
arguments[1](this.msg)
}
}
5. 觀察者模式
又稱發(fā)布-訂閱模式, 舉例子說明.
實現(xiàn): 發(fā)布者管理訂閱者隊列, 并有新消息推送功能. 訂閱者僅關(guān)注更新就行
6. 手寫實現(xiàn)bind
Function.prototype.bind=function () {
// 保存原函數(shù)
var self=this
// 取出第一個參數(shù)作為上下文, 相當(dāng)于[].shift.call(arguments)
var context=Array.prototype.shift.call(arguments)
// 取剩余的參數(shù)作為arg; 因為arguments是偽數(shù)組, 所以要轉(zhuǎn)化為數(shù)組才能使用數(shù)組方法
var arg=Array.prototype.slice.call(arguments)
// 返回一個新函數(shù)
return function () {
// 綁定上下文并傳參
self.apply(context, Array.prototype.concat.call(arg, Array.prototype.slice.call(arguments)))
}
}
7. 手寫實現(xiàn)4種繼承
<p style="font-size: 20px"> 123 <p style="font-size: 2em;width: 2em">456</p> </p>// 此時子元素的font-size為40px, 寬度為80px(還要乘以子元素font-size的系數(shù))
8. css菊花圖
四個小圓點一直旋轉(zhuǎn)
// 父標(biāo)簽
animation: antRotate 1.2s infinite linear;
// 子標(biāo)簽
animation: antSpin 1s infinite linear;
@keyframe antSpin {
to {
opacity: 1
}
}
@keyframe antRotate {
to {
transform: rotate(405)
}
}
// animation-delay: 逐個延遲0.4s
9. http狀態(tài)碼
10. Object.create實現(xiàn)(原型式繼承,特點:實例的proto指向構(gòu)造函數(shù)本身)
11. async和await:
12. 算法和數(shù)據(jù)結(jié)構(gòu):
13. 封裝JSONP
function jsonp ({url, param, callback}) {
return new Promise((resolve, reject)=> {
var script=document.createElement('script')
window.callback=function (data) {
resolve(data)
document.body.removeChild('script')
}
var param={...param, callback}
var arr=[]
for (let key in param) {
arr.push(`${key}=${param[key]}`)
}
script.src=`${url}?${arr.join('&')}`
document.body.appendChild(script)
})
}
14. 手動實現(xiàn)map(forEach以及filter也類似)
// for循環(huán)實現(xiàn)
Array.prototype.myMap=function () {
var arr=this
var [fn, thisValue]=Array.prototype.slice.call(arguments)
var result=[]
for (var i=0; i < arr.length; i++) {
result.push(fn.call(thisValue, arr[i], i, arr))
}
return result
}
var arr0=[1, 2, 3]
console.log(arr0.myMap(v=> v + 1))
// forEach實現(xiàn)(reduce類似)
Array.prototype.myMap=function (fn, thisValue) {
var result=[]
this.forEach((v, i, arr)=> {
result.push(fn.call(thisValue, v, i, arr))
})
return result
}
var arr0=[1, 2, 3]
console.log(arr0.myMap(v=> v + 1))
15. js實現(xiàn)checkbox全選以及反選
<body>
<button id="other">反選</button>
<input type="checkbox" id="all" />全選
<input type="checkbox" class="check" />1
<input type="checkbox" class="check" />2
<input type="checkbox" class="check" />3
<script>
var checkbox=document.getElementsByClassName('check')
var checkAll=document.getElementById('all')
var checkOther=document.getElementById('other')
checkAll.onclick=function() {
var flag=true
for (var i=0; i < checkbox.length; i++) {
if (!checkbox[i].checked) flag=false
}
if (flag) {
for (var i=0; i < checkbox.length; i++) {
checkbox[i].checked=false
}
} else {
for (var i=0; i < checkbox.length; i++) {
checkbox[i].checked=true
}
}
}
checkOther.onclick=function() {
for (var i=0; i < checkbox.length; i++) {
checkbox[i].checked=!checkbox[i].checked
}
}
</script>
</body>
16. 對原型鏈的理解?prototype上都有哪些屬性
17. 為什么使用繼承
通常在一般的項目里不需要,因為應(yīng)用簡單,但你要用純js做一些復(fù)雜的工具或框架系統(tǒng)就要用到了,比如webgis、或者js框架如jquery、ext什么的,不然一個幾千行代碼的框架不用繼承得寫幾萬行,甚至還無法維護(hù)。
18. setTimeout時間延遲為何不準(zhǔn)
單線程, 先執(zhí)行同步主線程, 再執(zhí)行異步任務(wù)隊列
19. 事件循環(huán)述,宏任務(wù)和微任務(wù)有什么區(qū)別?
20. let const var作用域
塊級作用域, 暫時性死區(qū)
21. 節(jié)流和防抖
// 函數(shù)節(jié)流 滾動條滾動
var canRun=true;
document.getElementById("throttle").onscroll=function(){
if(!canRun){
// 判斷是否已空閑,如果在執(zhí)行中,則直接return
return;
}
canRun=false;
setTimeout(function(){
console.log("函數(shù)節(jié)流");
canRun=true;
}, 300);
};
// 函數(shù)防抖
var timer=false;
document.getElementById("debounce").onscroll=function(){
clearTimeout(timer); // 清除未執(zhí)行的代碼,重置回初始化狀態(tài)
timer=setTimeout(function(){
console.log("函數(shù)防抖");
}, 300);
};
22. 實現(xiàn)一個sleep函數(shù)
// 這種實現(xiàn)方式是利用一個偽死循環(huán)阻塞主線程。因為JS是單線程的。所以通過這種方式可以實現(xiàn)真正意義上的sleep()。
function sleep(delay) {
var start=(new Date()).getTime();
while ((new Date()).getTime() - start < delay) {
continue;
}
}
function test() {
console.log('111');
sleep(2000);
console.log('222');
}
test()
23. 閉包
24. Immutable.js
Facebook出品, 倡導(dǎo)數(shù)據(jù)的不可變性, 用的最多就是List和Map.
25. js實現(xiàn)instanceof
// 檢測l的原型鏈(__proto__)上是否有r.prototype,若有返回true,否則false
function myInstanceof (l, r) {
var R=r.prototype
while (l.__proto__) {
if (l.__proto__===R) return true
}
return false
}
27. ES6的模塊引入和CommonJs區(qū)別
28. 嚴(yán)格模式
// 嚴(yán)格模式下, 隱式綁定丟失后this不會指向window, 而是指向undefined
'use strict'
var a=2
var obj={
a: 1,
b: function() {
// console.log(this.a)
console.log(this)
}
}
var c=obj.b
c() // undefined
29. fetch, axios區(qū)別
30. typescript缺點
31. 構(gòu)造函數(shù)實現(xiàn)原理
// 模擬構(gòu)造函數(shù)實現(xiàn)
var Book=function(name) {
this.name=name;
};
//正常用法
var java=new Book(‘Master Java’);
//使用代碼模擬,在非IE瀏覽器中測試,IE瀏覽器不支持
var python={};
python.__proto__=Book.prototype;
Book.call(python, 'Master Python');
32. for in 和 for of區(qū)別
33. JS實現(xiàn)并發(fā)控制:
使用消息隊列以及setInterval或promise進(jìn)行入隊和出隊
34. ajax和axios、fetch的區(qū)別
35. promise.finally實現(xiàn)
Promise.prototype.finally=function (callback) {
let P=this.constructor;
return this.then(
value=> P.resolve(callback()).then(()=> value),
reason=> P.resolve(callback()).then(()=> { throw reason })
);
};
1. reflow(回流)和repaint(重繪)優(yōu)化
2.一個頁面從輸入 URL 到頁面加載顯示完成,這個過程中都發(fā)生了什么?
3.localStorage 與 sessionStorage 與cookie的區(qū)別總結(jié)
4.瀏覽器如何阻止事件傳播,阻止默認(rèn)行為
5.虛擬DOM方案相對原生DOM操作有什么優(yōu)點,實現(xiàn)上是什么原理?
虛擬DOM可提升性能, 無須整體重新渲染, 而是局部刷新.
JS對象, diff算法
6.瀏覽器事件機(jī)制中事件觸發(fā)三個階段
7.什么是跨域?為什么瀏覽器要使用同源策略?你有幾種方式可以解決跨域問題?了解預(yù)檢請求嗎?
8.了解瀏覽器緩存機(jī)制嗎?
9.為什么操作 DOM 慢?
DOM本身是一個js對象, 操作這個對象本身不慢, 但是操作后觸發(fā)了瀏覽器的行為, 如repaint和reflow等瀏覽器行為, 使其變慢
10.什么情況會阻塞渲染?
11.如何判斷js運行在瀏覽器中還是node中?
判斷有無全局對象global和window
12.關(guān)于web以及瀏覽器處理預(yù)加載有哪些思考?
圖片等靜態(tài)資源在使用之前就提前請求
資源使用到的時候能從緩存中加載, 提升用戶體驗
頁面展示的依賴關(guān)系維護(hù)
13.http多路復(fù)用
14. http和https:
15. CSRF和XSS區(qū)別及防御
16. cookie可設(shè)置哪些屬性?httponly?
chrome控制臺的application下可查看:
17. 登錄后,前端做了哪些工作,如何得知已登錄
18. http狀態(tài)碼
19. # Http請求頭緩存設(shè)置方法
Cache-control, expire, last-modify
20. 實現(xiàn)頁面回退刷新
21. 正向代理和反向代理
(1)訪問原來無法訪問的資源,如google
(2) 可以做緩存,加速訪問資源
(3)對客戶端訪問授權(quán),上網(wǎng)進(jìn)行認(rèn)證
(4)代理可以記錄用戶訪問記錄(上網(wǎng)行為管理),對外隱藏用戶信息
(1)保證內(nèi)網(wǎng)的安全,可以使用反向代理提供WAF功能,阻止web攻擊大型網(wǎng)站,通常將反向代理作為公網(wǎng)訪問地址,Web服務(wù)器是內(nèi)網(wǎng)。
(2)負(fù)載均衡,通過反向代理服務(wù)器來優(yōu)化網(wǎng)站的負(fù)載
22. 關(guān)于預(yù)檢請求
在非簡單請求且跨域的情況下,瀏覽器會自動發(fā)起options預(yù)檢請求。
23. 三次握手四次揮手
24. TCP和UDP協(xié)議
25. 進(jìn)程和線程的區(qū)別
1. 生命周期
2 .雙向數(shù)據(jù)綁定v-model。這個最好也是自己實現(xiàn)一下 理解更深
通過v-model
VUE實現(xiàn)雙向數(shù)據(jù)綁定的原理就是利用了 Object.defineProperty() 這個方法重新定義了對象獲取屬性值(get)和設(shè)置屬性值(set)的操作來實現(xiàn)的。
function* helloWorldGenerator() { yield 'hello'; yield 'world'; return 'ending';}var hw=helloWorldGenerator();
3.vue父子組件傳遞參數(shù)
4.vue傳遞參數(shù)方法
hw.next()// { value: 'hello', done: false }hw.next()// { value: 'world', done: false }hw.next()// { value: 'ending', done: true }hw.next()// { value: undefined, done: true }
5.vue自定義組件
可以使用獨立可復(fù)用的自定義組件來構(gòu)成大型應(yīng)用, 采用帕斯卡命名法或橫線連接, 通過以上方式進(jìn)行組件間通信. 每一個組件都是Vue實例, 可以使用生命周期鉤子.
6. vue自定義指令
7.vuex組成和原理
8.vue-router的原理,例如hashhistory和History interface這些東西要弄明白。其實看一下源碼就好了,看不懂可以直接看解析的相關(guān)技術(shù)博客。
9.vue的seo問題
seo關(guān)系到網(wǎng)站排名, vue搭建spa做前后端分離不好做seo, 可通過其他方法解決:
10.預(yù)渲染和ssr
以上
11.生命周期內(nèi)create和mounted的區(qū)別
12.監(jiān)聽watch
對應(yīng)一個對象,鍵是觀察表達(dá)式,值是對應(yīng)回調(diào)。值也可以是methods的方法名,或者是對象,包含選項。在實例化時為每個鍵調(diào)用 $watch()
13.登錄驗證攔截(通過router)
var myPromise=new Promise((resolve, reject)=> { // 需要執(zhí)行的代碼 ... if (/* 異步執(zhí)行成功 */) { resolve(value) } else if (/* 異步執(zhí)行失敗 */) { reject(error) }})myPromise.then((value)=> { // 成功后調(diào)用, 使用value值}, (error)=> { // 失敗后調(diào)用, 獲取錯誤信息error})
router.beforeEach((from, to, next)=> {
if (to.meta.requireAuth) { // 判斷跳轉(zhuǎn)的路由是否需要登錄
if (store.state.token) { // vuex.state判斷token是否存在
next() // 已登錄
} else {
next({
path: '/login',
query: {redirect: to.fullPath} // 將跳轉(zhuǎn)的路由path作為參數(shù),登錄成功后跳轉(zhuǎn)到該路由
})
}
} else {
next()
}
})
14. v-for key值
不寫key值會報warning, 和react的array渲染類似. 根據(jù)diff算法, 修改數(shù)組后, 寫key值會復(fù)用, 不寫會重新生成, 造成性能浪費或某些不必要的錯誤
15. vue3.0的更新和defineProperty優(yōu)化
15. vue使用this獲取變量
正常要通過vm.[圖片上傳失敗...(image-6d2f4e-1570591304185)]
root傳參取值
16. jQuery的優(yōu)缺點,與vue的不同,vue的優(yōu)缺點?
17. vue解除雙向綁定
function promise () { this.msg='' // 存放value和error this.status='pending' var that=this var process=arguments[0] process (function () { that.status='fulfilled' that.msg=arguments[0] }, function () { that.status='rejected' that.msg=arguments[0] }) return this}promise.prototype.then=function () { if (this.status==='fulfilled') { arguments[0](this.msg) } else if (this.status==='rejected' && arguments[1]) { arguments[1](this.msg) }}
18. vue異步組件
為了簡化,Vue 允許你以一個工廠函數(shù)的方式定義你的組件,這個工廠函數(shù)會異步解析你的組件定義。Vue 只有在這個組件需要被渲染的時候才會觸發(fā)該工廠函數(shù),且會把結(jié)果緩存起來供未來重渲染
Vue.component(
'async-webpack-example',
// 這個 `import` 函數(shù)會返回一個 `Promise` 對象。
()=> import('./my-async-component')
)
19. MVC與MVVM
20. vue漸進(jìn)式
小到可以只使用核心功能,比如單文件組件作為一部分嵌入;大到使用整個工程,vue init webpack my-project來構(gòu)建項目;VUE的核心庫及其生態(tài)系統(tǒng)也可以滿足你的各式需求(core+vuex+vue-route)
1. 新舊生命周期
2. react核心
3. fiber核心(react 16)
4. 渲染一個react
5. 高階組件
高階組件就是一個函數(shù),且該函數(shù)(wrapper)接受一個組件作為參數(shù),并返回一個新的組件。
高階組件并不關(guān)心數(shù)據(jù)使用的方式和原因,而被包裹的組件也不關(guān)心數(shù)據(jù)來自何處.
6. hook(v16.7測試)
在無狀態(tài)組件(如函數(shù)式組件)中也能操作state以及其他react特性, 通過useState
7. redux和vuex以及dva:
8. react和vue的區(qū)別
9. react單向數(shù)據(jù)流怎么理解
React是單向數(shù)據(jù)流,數(shù)據(jù)主要從父節(jié)點傳遞到子節(jié)點(通過props)。如果頂層(父級)的某個props改變了,React會重渲染所有的子節(jié)點。
10. React算法復(fù)雜度優(yōu)化
react樹對比是按照層級去對比的, 他會給樹編號0,1,2,3,4.... 然后相同的編號進(jìn)行比較。所以復(fù)雜度是n,這個好理解。
關(guān)鍵是傳統(tǒng)diff的復(fù)雜度是怎么算的?傳統(tǒng)的diff需要出了上面的比較之外,還需要跨級比較。他會將兩個樹的節(jié)點,兩兩比較,這就有n^2的復(fù)雜度了。然后還需要編輯樹,編輯的樹可能發(fā)生在任何節(jié)點,需要對樹進(jìn)行再一次遍歷操作,因此復(fù)雜度為n。加起來就是n^3了。
11. React優(yōu)點
聲明式, 組件化, 一次學(xué)習(xí), 隨處編寫. 靈活, 豐富, 輕巧, 高效
1. 移動端兼容適配
2. flexible如何實現(xiàn)自動判斷dpr
判斷機(jī)型, 找出樣本機(jī)型去適配. 比如iphone以6為樣本, 寬度375px, dpr是2
3. 為什么以iPhone6為標(biāo)準(zhǔn)的設(shè)計稿的尺寸是以750px寬度來設(shè)計的呢?
iPhone6的滿屏寬度是375px,而iPhone6采用的視網(wǎng)膜屏的物理像素是滿屏寬度的2倍,也就是dpr(設(shè)備像素比)為2, 并且設(shè)計師所用的PS設(shè)計軟件分辨率和像素關(guān)系是1:1。所以為了做出的清晰的頁面,設(shè)計師一般給出750px的設(shè)計圖,我們再根據(jù)需求對元素的尺寸設(shè)計和壓縮。
4. 如何處理異形屏iphone X
5. 移動端首屏優(yōu)化
6. PWA全稱Progressive Web App,即漸進(jìn)式WEB應(yīng)用
一個 PWA 應(yīng)用首先是一個網(wǎng)頁, 可以通過 Web 技術(shù)編寫出一個網(wǎng)頁應(yīng)用. 隨后添加上 App Manifest 和 Service Worker 來實現(xiàn) PWA 的安裝和離線等功能
解決了哪些問題?
7. 離線包方案
現(xiàn)在 web 頁面在移動端的地位越來越高,大部分主流 App 采用 native + webview 的 hybrid 模式,加載遠(yuǎn)程頁面受限于網(wǎng)絡(luò),本地 webview 引擎,經(jīng)常會出現(xiàn)渲染慢導(dǎo)致的白屏現(xiàn)象,體驗很差,于是離線包方案應(yīng)運而生。動態(tài)下載的離線包可以使得我們不需要走完整的 App 審核發(fā)布流程就完成了版本的更新
8. 自適應(yīng)和響應(yīng)式布局的區(qū)別
1. babel和polyfill
2. jpg, jpeg和png區(qū)別
3. git rebase和merge區(qū)別
1.JSBridge通信原理, 有哪幾種實現(xiàn)的方式?
JsBridge給JavaScript提供了調(diào)用Native功能,Native也能夠操控JavaScript。這樣前端部分就可以方便使用地理位置、攝像頭以及登錄支付等Native能力啦。JSBridge構(gòu)建 Native和非Native間消息通信的通道,而且是 雙向通信的通道。
2.實現(xiàn)一個簡單的 JSBridge,設(shè)計思路?
1. 二分查找和冒泡排序
2. 快速排序
Function.prototype.bind=function () { // 保存原函數(shù) var self=this // 取出第一個參數(shù)作為上下文, 相當(dāng)于[].shift.call(arguments) var context=Array.prototype.shift.call(arguments) // 取剩余的參數(shù)作為arg; 因為arguments是偽數(shù)組, 所以要轉(zhuǎn)化為數(shù)組才能使用數(shù)組方法 var arg=Array.prototype.slice.call(arguments) // 返回一個新函數(shù) return function () { // 綁定上下文并傳參 self.apply(context, Array.prototype.concat.call(arg, Array.prototype.slice.call(arguments))) }}
3. 最長公共子串
function Father () {}function Child () {}// 1\. 原型繼承Child.prototype=new Father()// 2\. 構(gòu)造繼承function Child (name) { Father.call(this, name)}// 3\. 組合繼承function Child (name) { Father.call(this, name)}Child.prototype=new Father()// 4\. 寄生繼承function cloneObj (o) { var clone=object.create(o) clone.sayName=... return clone}// 5\. 寄生組合繼承// 6\. ES6 class extend繼承
4. 最長公共子序列(LCS動態(tài)規(guī)劃)
另一篇
// 父標(biāo)簽animation: antRotate 1.2s infinite linear;// 子標(biāo)簽animation: antSpin 1s infinite linear;@keyframe antSpin { to { opacity: 1 }}@keyframe antRotate { to { transform: rotate(405) }}// animation-delay: 逐個延遲0.4s
5. 數(shù)組去重,多種方法
6. 實現(xiàn)一個函數(shù)功能:sum(1,2,3,4..n)轉(zhuǎn)化為 sum(1)(2)(3)(4)…(n)
// 使用柯里化 + 遞歸
function curry ( fn ) {
var c=(...arg)=> (fn.length===arg.length) ?
fn (...arg) : (...arg1)=> c(...arg, ...arg1)
return c
}
7. 反轉(zhuǎn)二叉樹
var invertTree=function (root) {
if (root !==null) {
[root.left, root.right]=[root.right, root.left]
invertTree(root.left)
invertTree(root.right)
}
return root
}
8. 貪心算法解決背包問題
var items=['A','B','C','D']
var values=[50,220,60,60]
var weights=[5,20,10,12]
var capacity=32 //背包容積
greedy(values, weights, capacity) // 320
function greedy(values, weights, capacity) {
var result=0
var rest=capacity
var sortArray=[]
var num=0
values.forEach((v, i)=> {
sortArray.push({
value: v,
weight: weights[i],
ratio: v / weights[i]
})
})
sortArray.sort((a, b)=> b.ratio - a.ratio)
sortArray.forEach((v, i)=> {
num=parseInt(rest / v.weight)
rest -=num * v.weight
result +=num * v.value
})
return result
}
9. 輸入一個遞增排序的數(shù)組和一個數(shù)字S,在數(shù)組中查找兩個數(shù),使得他們的和正好是S,如果有多對數(shù)字的和等于S,輸出兩個數(shù)的乘積最小的。
function FindNumbersWithSum(array, sum)
{
var index=0
for (var i=0; i < array.length - 1 && array[i] < sum / 2; i++) {
for (var j=i + 1; j < array.length; j++) {
if (array[i] + array[j]===sum) return [array[i], array[j]]
}
//index=array.indexOf(sum - array[i], i + 1)
// if (index !==-1) {
// return [array[i], array[index]]
//}
}
return []
10. 二叉樹各種(層序)遍歷
深度廣度遍歷
// 根據(jù)前序和中序重建二叉樹
/* function TreeNode(x) {
this.val=x;
this.left=null;
this.right=null;
} */
function reConstructBinaryTree(pre, vin)
{
var result=null
if (pre.length===1) {
result={
val: pre[0],
left: null,
right: null
}
} else if (pre.length > 1) {
var root=pre[0]
var vinRootIndex=vin.indexOf(root)
var vinLeft=vin.slice(0, vinRootIndex)
var vinRight=vin.slice(vinRootIndex + 1, vin.length)
pre.shift()
var preLeft=pre.slice(0, vinLeft.length)
var preRight=pre.slice(vinLeft.length, pre.length)
result={
val: root,
left: reConstructBinaryTree(preLeft, vinLeft),
right: reConstructBinaryTree(preRight, vinRight)
}
}
return result
}
// 遞歸
// 前序遍歷
function prevTraverse (node) {
if (node===null) return;
console.log(node.data);
prevTraverse(node.left);
prevTraverse(node.right);
}
// 中序遍歷
function middleTraverse (node) {
if (node===null) return;
middleTraverse(node.left);
console.log(node.data);
middleTraverse(node.right);
}
// 后序遍歷
function lastTraverse (node) {
if (node===null) return;
lastTraverse(node.left);
lastTraverse(node.right);
console.log(node.data);
}
// 非遞歸
// 前序遍歷
function preTraverse(tree) {
var arr=[],
node=null
arr.unshift(tree)
while (arr.length) {
node=arr.shift()
console.log(node.root)
if (node.right) arr.unshift(node.right)
if (node.left) arr.unshift(node.left)
}
}
// 中序遍歷
function middleTraverseUnRecursion (root) {
let arr=[],
node=root;
while (arr.length !==0 || node !==null) {
if (node===null) {
node=arr.shift();
console.log(node.data);
node=node.right;
} else {
arr.unshift(node);
node=node.left;
}
}
}
// 廣度優(yōu)先-層序遍歷
// 遞歸
var result=[]
var stack=[tree]
var count=0
var bfs=function () {
var node=stack[count]
if (node) {
result.push(node.value)
if (node.left) stack.push(node.left)
if (node.right) stack.push(node.right)
count++
bfs()
}
}
bfs()
console.log(result)
// 非遞歸
function bfs (node) {
var result=[]
var queue=[]
queue.push(node)
while (queue.length) {
node=queue.shift()
result.push(node.value)
node.left && queue.push(node.left)
node.right && queue.push(node.right)
}
return result
}
11. 各種排序
// 插入排序
function insertSort(arr) {
var temp
for (var i=1; i < arr.length; i++) {
temp=arr[i]
for (var j=i; j > 0 && temp < arr[j - 1]; j--) {
arr[j]=arr[j - 1]
}
arr[j]=temp
}
return arr
}
console.log(insertSort([3, 1, 8, 2, 5]))
// 歸并排序
function mergeSort(array) {
var result=array.slice(0)
function sort(array) {
var length=array.length
var mid=Math.floor(length * 0.5)
var left=array.slice(0, mid)
var right=array.slice(mid, length)
if (length===1) return array
return merge(sort(left), sort(right))
}
function merge(left, right) {
var result=[]
while (left.length || right.length) {
if (left.length && right.length) {
if (left[0] < right[0]) {
result.push(left.shift())
} else {
result.push(right.shift())
}
} else if (left.length) {
result.push(left.shift())
} else {
result.push(right.shift())
}
}
return result
}
return sort(result)
}
console.log(mergeSort([5, 2, 8, 3, 6]))
// 二分插入排序
function twoSort(array) {
var len=array.length,
i,
j,
tmp,
low,
high,
mid,
result
result=array.slice(0)
for (i=1; i < len; i++) {
tmp=result[i]
low=0
high=i - 1
while (low <=high) {
mid=parseInt((high + low) / 2, 10)
if (tmp < result[mid]) {
high=mid - 1
} else {
low=mid + 1
}
}
for (j=i - 1; j >=high + 1; j--) {
result[j + 1]=result[j]
}
result[j + 1]=tmp
}
return result
}
console.log(twoSort([4, 1, 7, 2, 5]))
12. 使用尾遞歸對斐波那契優(yōu)化
遞歸非常耗費內(nèi)存,因為需要同時保存成千上百個調(diào)用幀,很容易發(fā)生“棧溢出”錯誤(stack overflow)。但對于尾遞歸來說,由于只存在一個調(diào)用幀,所以永遠(yuǎn)不會發(fā)生“棧溢出”錯誤。
// 傳統(tǒng)遞歸斐波那契, 會造成超時或溢出
function Fibonacci (n) {
if ( n <=1 ) {return 1};
return Fibonacci(n - 1) + Fibonacci(n - 2);
}
Fibonacci(10) // 89
Fibonacci(100) // 超時
Fibonacci(500) // 超時
// 使用尾遞歸優(yōu)化, 可規(guī)避風(fēng)險
function Fibonacci2 (n , ac1=1 , ac2=1) {
if( n <=1 ) {return ac2};
return Fibonacci2 (n - 1, ac2, ac1 + ac2);
}
Fibonacci2(100) // 573147844013817200000
Fibonacci2(1000) // 7.0330367711422765e+208
Fibonacci2(10000) // Infinity
13. 兩個升序數(shù)組合并為一個升序數(shù)組
function sort (A, B) {
var i=0, j=0, p=0, m=A.length, n=B.length, C=[]
while (i < m || j < n) {
if (i < m && j < n) {
C[p++]=A[i] < B[j] ? A[i++] : B[j++]
} else if (i < m) {
C[p++]=A[i++]
} else {
C[p++]=B[j++]
}
}
return C
}
1. node的router是什么
2. 數(shù)據(jù)庫索引是啥
3. 瀏覽器的事件循環(huán)和node事件循環(huán)有什么區(qū)別?
以上就是前端面試題全面整理-帶解析 涵蓋(css、js、瀏覽器、vue、react、移動web、前端性能、算法、node)的詳細(xì)內(nèi)容,更多請關(guān)注html中文網(wǎng)其它相關(guān)文章!
我是@半糖學(xué)前端 ,專注前端技術(shù)領(lǐng)域分享,一個前端從業(yè)者,關(guān)注我和我一起學(xué)習(xí),共同進(jìn)步!
*請認(rèn)真填寫需求信息,我們會在24小時內(nèi)與您取得聯(lián)系。