任云峰 發表於 2021-5-6 18:37:00

前端开发面试总结

<p><span style="font-size: 18pt"><strong>HTML</strong></span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>HTML5 有哪些新特性?</strong></span></p>
</li>
</ul>
<pre>* HTML5 现在已经不是 SGML 的子集<span style="font-size: 12px">,主要是关于图</span>像,位置,存储,多任务等功能的增加。</pre>
<pre>* 拖拽释放(Drag and drop) API </pre>
<pre>&nbsp;&nbsp;语义化更好的内容标签(header,nav,footer,aside,article,section)</pre>
<pre> &nbsp;音频、视频API(audio,video)</pre>
<pre> &nbsp;画布(Canvas) API</pre>
<pre> &nbsp;地理(Geolocation) API</pre>
<pre> &nbsp;本地离线存储 localStorage 长期存储数据,浏览器关闭后数据不丢失;sessionStorage 的数据在浏览器关闭后自动删除</pre>
<pre> &nbsp;表单控件,calendar、date、time、email、url、search &nbsp;</pre>
<pre> &nbsp;新的技术webworker, websocket, Geolocation</pre>
<pre>* 移除的元素</pre>
<pre>纯表现的元素:basefont,big,center,font, s,strike,tt,u;</pre>
<pre>对可用性产生负面影响的元素:frame,frameset,noframes;</pre>
<pre>支持HTML5新标签:</pre>
<pre>* IE8/IE7/IE6支持通过document.createElement方法产生的标签,</pre>
<pre> &nbsp;可以利用这一特性让这些浏览器支持HTML5新标签,</pre>
<pre> &nbsp;浏览器支持新标签后,还需要添加标签默认的样式:</pre>
<pre>* 当然最好的方式是直接使用成熟的框架、使用最多的是html5shim框架</pre>
<pre> &nbsp; &lt;!--&gt; </pre>
<pre>&nbsp;&nbsp; &lt;script&gt; src="http://html5shim.googlecode.com/svn/trunk/html5.js"&lt;/script&gt; </pre>
<pre>&nbsp;&nbsp; &lt;!--&gt; </pre>
<pre>  如何区分: DOCTYPE声明\新增的结构元素\功能元素</pre>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>Doctype作⽤? 严格模式与混杂模式如何区分?它们有何意义?</strong></span></p>
</li>
</ul>
<h4 id="Z72Jg" style="margin-left: 30px" data-lake-id="Z72Jg" data-wording="true">一、Doctype作用是什么?</h4>
<p style="margin-left: 30px" data-lake-id="u6bce7fac" data-wording="true"><span class="lake-fontsize-12">&lt;!DOCTYPE&gt;声明叫做文件类型定义(DTD),声明的作用为了告诉浏览器该文件的类型。让浏览器解析器知道应该用哪个规范来解析文档。&lt;!DOCTYPE&gt;声明必须在 HTML 文档的第一行,这并不是一个 HTML 标签。</span></p>
<h4 id="DAz9N" style="margin-left: 30px" data-lake-id="DAz9N" data-wording="true">二、严格模式和混杂模式的如何区分?他们有什么意义?</h4>
<p style="margin-left: 30px" data-lake-id="u6a6d81b0" data-wording="true"><span class="lake-fontsize-12"><span style="background-color: rgba(255, 255, 0, 1)">标准模式</span><span class="lake-fontsize-12">(严格模式)的排版和JS运作模式都是以该浏览器支持的最高标准运行。</span></span></p>
<p style="margin-left: 30px" data-lake-id="u4690e619" data-wording="true"><span class="lake-fontsize-12"><span style="background-color: rgba(255, 255, 0, 1)">在兼容模式</span><span class="lake-fontsize-12">(混杂模式或怪异模式)中,页面以宽松的向后兼容的方式显示,模拟老式浏览器的行为以防止站点无法工作。</span></span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">如何实现浏览器内多个标签页之间的通信?</span></strong></span></p>
</li>
</ul>
<p style="margin-left: 30px" data-lake-id="ufa9e44ab" data-wording="true"><span class="lake-fontsize-12">一、调用localStorage</span></p>
<p style="margin-left: 30px" data-lake-id="ua696a524" data-wording="true"><span class="lake-fontsize-12">在一个标签页里面使用<span class="lake-fontsize-11"><span style="background-color: rgba(255, 255, 0, 1)">localStorage.setItem(key,value)</span><span class="lake-fontsize-12">添加(修改、删除)内容;在另一个标签页里面监听<span class="lake-fontsize-11"><span style="background-color: rgba(255, 255, 0, 1)">storage</span><span class="lake-fontsize-12">事件。通过<span class="lake-fontsize-11"><span style="background-color: rgba(255, 255, 0, 1)">localstorge.getItem(key)</span><span class="lake-fontsize-12">存储的值,实现不同标签页之间的通信。</span></span></span></span></span></span></span>&nbsp;</p>
<p style="margin-left: 30px" data-lake-id="ub8dc19bf" data-wording="true"><span class="lake-fontsize-12">二、<span class="lake-fontsize-12">调用<span class="lake-fontsize-12" style="background-color: rgba(255, 255, 0, 1)">cookie+setInterval()</span></span></span>&nbsp;</p>
<p style="margin-left: 30px" data-lake-id="u8dddd1c0" data-wording="true"><span class="lake-fontsize-12">将要传递的信息存储在cookie中,每隔一定时间读取getCookie获取信息,即可随时获取要传递的信息。</span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">行内元素有哪些?块级元素有哪些?空(void)元素有哪些?<strong>行</strong>内元素和块级元素有什么区别?</span></strong></span></p>
</li>
</ul>
<p style="margin-left: 60px" data-lake-id="u2745276a" data-wording="true"><span class="lake-fontsize-12">行内元素有: a、b、span、img、input、select、strong</span></p>
<p style="margin-left: 60px" data-lake-id="u99199e4b" data-wording="true"><span class="lake-fontsize-12">块级元素有: div、ul、ol、li、dl、dt、dd、h1、h2、h3、h4、 p</span></p>
<p style="margin-left: 60px" data-lake-id="u7b4bc94d" data-wording="true"><span class="lake-fontsize-12">空元素: br、hr、img、input、link、meta</span></p>
<p id="uKTdH" data-lake-id="uKTdH" data-wording="true">    <span style="background-color: rgba(255, 255, 0, 1)">区别:</span></p>
<p style="margin-left: 60px" data-lake-id="u3db08606" data-wording="true"><span class="lake-fontsize-12">行内元素不可以设置宽高,不独占整行</span></p>
<p style="margin-left: 60px" data-lake-id="u8eead91d" data-wording="true"><span class="lake-fontsize-12">块级元素可以设置宽高,独占整行</span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">简述一下src与href的区别?</span></strong></span></p>
</li>
</ul>
<p style="margin-left: 30px" data-lake-id="ufdc7e86f" data-wording="true"><span class="lake-fontsize-12">src用于替换当前元素;href用于在当前文档和引用资源之间确立联系。</span></p>
<p style="margin-left: 30px" data-lake-id="u4204b728" data-wording="true"><span class="lake-fontsize-12">src是source的缩写,指向外部资源的位置,指向的内容将会嵌入到文档中当前标签所在位置</span></p>
<p style="margin-left: 30px" data-lake-id="uf915a6e2" data-wording="true"><span class="lake-fontsize-12">href是Hypertext Reference的缩写,指向网络资源所在位置,建立和当前元素(锚点)或当前文档(链接)之间的链接</span></p>
<p style="margin-left: 30px">&lt;script src =<span class="hljs-string">"js.js"&gt;&lt;/script&gt; </span></p>
<p style="margin-left: 30px"><span class="hljs-string">&lt;link href=<span class="hljs-string">"common.css" rel=<span class="hljs-string">"stylesheet"/&gt;</span></span></span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px"><strong>浏览器本地存储&nbsp;</strong>cookies,sessionStorage,localStorage 的区别?</span></strong></span></p>
<p>在较高版本的浏览器中,js提供了sessionStorage和globalStorage。在HTML5中提供了localStorage来取代globalStorage。</p>
<p>html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage。</p>
<p>sessionStorage用于本地存储一个会话(session)中的数据,这些数据只有在同一个会话中的页面才能访问并且当会话结束后数据也随之销毁。因此sessionStorage不是一种持久化的本地存储,仅仅是会话级别的存储。</p>
<p>而localStorage用于持久化的本地存储,除非主动删除数据,否则数据是永远不会过期的。</p>
<h3><strong>web storage</strong><strong>和cookie的区别</strong></h3>
<p>Web Storage的概念和cookie相似,区别是它是为了更大容量存储设计的。Cookie的大小是受限的,并且每次你请求一个新的页面的时候Cookie都会被发送过去,这样无形中浪费了带宽,另外cookie还需要指定作用域,不可以跨域调用。</p>
<p>除此之外,Web Storage拥有setItem,getItem,removeItem,clear等方法,不像cookie需要前端开发者自己封装setCookie,getCookie。</p>
<p>但是cookie也是不可以或缺的:cookie的作用是与服务器进行交互,作为HTTP规范的一部分而存在 ,而Web Storage仅仅是为了在本地“存储”数据而生</p>
<p>浏览器的支持除了IE7及以下不支持外,其他标准浏览器都完全支持(ie及FF需在web服务器里运行),值得一提的是IE总是办好事,例如IE7、IE6中的userData其实就是javascript本地存储的解决方案。通过简单的代码封装可以统一到所有的浏览器都支持web storage。</p>
<p>localStorage和sessionStorage都具有相同的操作方法,例如setItem、getItem和removeItem等</p>
<h3><strong>cookie&nbsp;</strong><strong>和session 的区别:</strong></h3>
<pre>&nbsp;1、cookie数据存放在客户的浏览器上,session数据放在服务器上。</pre>
<pre> 2、cookie不是很安全,别人可以分析存放在本地的COOKIE并进行COOKIE欺骗</pre>
<pre> &nbsp; &nbsp;考虑到安全应当使用session。</pre>
<pre> 3、session会在一定时间内保存在服务器上。当访问增多,会比较占用你服务器的性能</pre>
<pre> &nbsp; &nbsp;考虑到减轻服务器性能方面,应当使用COOKIE。</pre>
<pre> 4、单个cookie保存的数据不能超过4K,很多浏览器都限制一个站点最多保存20个cookie。</pre>
<pre> 5、所以个人建议:</pre>
<pre> &nbsp; &nbsp;将登陆信息等重要信息存放为SESSION</pre>
<pre> &nbsp; &nbsp;其他信息如果需要保留,可以放在COOKIE中</pre>
</li>
</ul>
<h3 style="margin-left: 30px"><strong>&nbsp; <span style="color: rgba(128, 0, 0, 1)">XML</span></strong><span style="color: rgba(128, 0, 0, 1)"><strong>和JSON的区别?</strong></span></h3>
<pre>   (1).数据体积方面。</pre>
<pre>    JSON相对于XML来讲,数据的体积小,传递的速度更快些。</pre>
<pre>   (2).数据交互方面。</pre>
<pre>    JSON与JavaScript的交互更加方便,更容易解析处理,更好的数据交互。</pre>
<pre>   (3).数据描述方面。</pre>
<pre>    JSON对数据的描述性比XML较差。</pre>
<pre>   (4).传输速度方面。</pre>
<pre>    JSON的速度要远远快于XML。</pre>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">浏览器是如何渲染页面的?</span></strong></span></p>
</li>
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">iframe 的优缺点?</span></strong></span></p>
</li>
</ul>
<p id="L66KA" style="margin-left: 60px" data-lake-id="L66KA" data-wording="true"><span style="background-color: rgba(255, 255, 0, 1)">iframe的优点</span>:</p>
<p style="margin-left: 60px" data-lake-id="u60d67a1c" data-wording="true"><span class="lake-fontsize-12">1.iframe能够原封不动的把嵌入的网页展现出来。</span></p>
<p style="margin-left: 60px" data-lake-id="ufb073697" data-wording="true"><span class="lake-fontsize-12">2.如果有多个网页引用iframe,那么你只需要修改iframe的内容,就可以实现调用的每一个页面内容的更改,方便快捷。</span></p>
<p style="margin-left: 60px" data-lake-id="u969a700e" data-wording="true"><span class="lake-fontsize-12">3.网页如果为了统一风格,头部和版本都是一样的,就可以写成一个页面,用iframe来嵌套,可以增加代码的可重用。</span></p>
<p style="margin-left: 60px" data-lake-id="u436f12af" data-wording="true"><span class="lake-fontsize-12">4.如果遇到加载缓慢的第三方内容如图标和广告,这些问题可以由iframe来解决。</span></p>
<p id="k8QCr" style="margin-left: 60px" data-lake-id="k8QCr" data-wording="true"><span style="background-color: rgba(255, 255, 0, 1)">iframe的缺点</span>:</p>
<p style="margin-left: 60px" data-lake-id="u3c377b1c" data-wording="true"><span class="lake-fontsize-12">1.会产生很多页面,不容易管理。</span></p>
<p style="margin-left: 60px" data-lake-id="u1d56f4d4" data-wording="true"><span class="lake-fontsize-12">2.如果框架个数多的话,可能会出现上下、左右滚动条,用户体验度差。</span></p>
<p style="margin-left: 60px" data-lake-id="u86d95d5c" data-wording="true"><span class="lake-fontsize-12">3.代码复杂,无法被一些搜索引擎索引到,使用iframe会不利于搜索引擎优化。</span></p>
<p style="margin-left: 60px" data-lake-id="u1f7dcc6f" data-wording="true"><span class="lake-fontsize-12">4.很多的移动设备(PDA 手机)无法完全显示框架,设备兼容性差。</span></p>
<p style="margin-left: 60px" data-lake-id="u8efdf6a2" data-wording="true"><span class="lake-fontsize-12">5.iframe框架页面会增加服务器的http请求,对于大型网站是不可取的。</span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">Canvas 和 SVG 图形的区别是什么?</span></strong></span></p>
</li>
</ul>
<p style="margin-left: 60px" data-lake-id="u41099195" data-wording="true"><span class="lake-fontsize-12" style="background-color: rgba(255, 255, 0, 1)">1.什么是Canvas?</span></p>
<p style="margin-left: 90px" data-lake-id="u120e4854" data-wording="true"><span class="lake-fontsize-12">Canvas 是H5新出来的标签</span></p>
<p style="margin-left: 90px" data-lake-id="uf2967163" data-wording="true"><span class="lake-fontsize-12">Canvas画布,利用JavaScript在网页绘制图像</span></p>
<p style="margin-left: 60px" data-lake-id="u0207edf3" data-wording="true"><span class="lake-fontsize-12" style="background-color: rgba(255, 255, 0, 1)">2.什么是SVG?</span></p>
<p style="margin-left: 90px" data-lake-id="uc1837b47" data-wording="true"><span class="lake-fontsize-12">SVG 可缩放矢量图形(Scalable Vector Graphics),基于可扩展标记语言XML</span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">谈一谈meta 标签?</span></strong></span></li>
</ul>
<p style="margin-left: 30px" data-lake-id="uf74103c4" data-wording="true"><span class="lake-fontsize-12">meta标签是用来描述一个HTML网页文档的属性,比<span style="font-size: 14px"><span style="font-size: 13px">如该网页的</span>作</span>者,日期,网页的关键字,刷新,网页等级设定等等</span></p>
<p style="margin-left: 30px" data-lake-id="uc0885827" data-wording="true"><span class="lake-fontsize-12" style="background-color: rgba(255, 255, 0, 1)">meta标签可以分为两大部分:</span></p>
<ul>
<li style="margin-left: 30px" data-lake-id="u215b21a3" data-wording="true"><span class="lake-fontsize-12">http-equiv: http标题信息</span></li>
<li style="margin-left: 30px" data-lake-id="uf8e06a31" data-wording="true"><span class="lake-fontsize-12">name:页面描述信息</span></li>
</ul>
<p style="margin-left: 30px" data-lake-id="u231b8ca6" data-wording="true"><span class="lake-fontsize-12">http-equiv 类似于http的头部协议,作用是回应给浏览器一些<span style="font-size: 14px">有用的信</span>息来帮助正确精确的显示网页内容。常用的http-equiv 类型有:Content-Type 和 Content-Language(显示字符集的设定)。</span></p>
<h4><strong><span style="font-size: 18pt">CSS 基础</span></strong></h4>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>px rem em区别&nbsp;</strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">一.px</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">1.相对长度单位。相对于显示器屏幕分辨率而言。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">2.存在浏览器不兼容问题。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">二.em</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">1.相对长度单位。相对于当前对象内文本字体尺寸。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">2.em值并不是固定的,em会继承父级元素的大小.</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">3.如果父级设置font-size:20px. 那么1em=20px. 2em=40px;如果父级设置font-size为30px. 1em=30px. 2em=60px.</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">4.存在容易造成字体设置混乱问题。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">三.rem</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">1.相对长度单位。相对于根节点html字体大小来计算。任意浏览器默认字体高都是16px.</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">2.如果html根节点设置字体font-size为100px. 则1em=100px. 2em=200px. 跟父级字体无关。</span>&nbsp;</p>
<p style="margin-left: 30px"><span style="font-size: 14px">3.浏览器兼容性比较好。</span></p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">display:none和visibility:hidden的区别?</span></strong></span></h3>
</li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">display:none</span>&nbsp;&nbsp;隐藏对应的元素,在文档布局中<span style="background-color: rgba(255, 255, 0, 1)">不再给它分配空间</span>,它各边的元素会合拢,<br>就当他从来不存在。<br><span style="background-color: rgba(255, 255, 0, 1)">visibility:hidden</span> &nbsp;隐藏对应的元素,但是在文档布局中<span style="background-color: rgba(255, 255, 0, 1)">仍保留原来的空间</span>。</span></p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>CSS中 link 和@import 的区别是?</strong></span></h3>































</li>































</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">(1)&nbsp;link属于HTML标签,而@import是CSS提供的;&nbsp;<br>(2)&nbsp;页面被加载的时,link会同时被加载,而@import引用的CSS会等到页面被加载完再加载;<br>(3)&nbsp;import只在IE5以上才能识别,而link是HTML标签,无兼容问题;&nbsp;<br>(4)&nbsp;link方式的样式的权重&nbsp;高于@import的权重.</span></p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>介绍一下box-sizing属性和盒模型?</strong></span></h3>































</li>































</ul>
<p style="margin-left: 30px">盒模型:content + border + padding +margin</p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">盒模型分为</span>:<span style="background-color: rgba(255, 255, 0, 1)">基本模型</span>(w3c标准盒模型)+<span style="background-color: rgba(255, 255, 0, 1)">IE模型</span>(基本模型width=content&nbsp; &nbsp; &nbsp; IE模型width=content+border+padding)</p>
<p style="margin-left: 30px">如何区分基本模型还是IE模型</p>
<p style="margin-left: 30px">Css3新增的属性Box-sizing 有两个值content-box(基本模型)和border-box(IE模型)</p>
<p style="margin-left: 30px">获取盒模型对应的宽高:dom.style.width/height</p>
<p style="margin-left: 30px" data-tool="mdnice编辑器"><code>box-sizing</code>属性主要用来控制元素的盒模型的解析模式。<span style="background-color: rgba(255, 255, 0, 1)">默认值是<code>content-box</code></span>。</p>
<ul>
<li style="margin-left: 30px" data-tool="mdnice编辑器"><code>content-box</code>:让元素维持<span style="background-color: rgba(255, 255, 0, 1)">W3C的标准盒模型</span>。元素的宽度/高度由border + padding + content的宽度/高度决定,设置<span style="background-color: rgba(255, 204, 153, 1)">width/height属性指的是content部分的宽/高</span></li>
<li style="margin-left: 30px" data-tool="mdnice编辑器"><code>border-box</code>:让元素维持I<span style="background-color: rgba(255, 255, 0, 1)">E传统盒模型</span>(IE6以下版本和IE6~7的怪异模式)。设置<span style="background-color: rgba(255, 204, 153, 1)">width/height属性指的是border + padding + content</span></li>































</ul>
<p style="margin-left: 30px" data-tool="mdnice编辑器">标准浏览器下,按照W3C规范对盒模型解析,一旦修改了元素的边框或内距,就会影响元素的盒子尺寸,就不得不重新计算元素的盒子尺寸,从而影响整个页面的布局。</p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">CSS 选择符有哪些?哪些属性可以继承?优先级算法如何计算?CSS3新增伪类有那些?</span></strong></span></h3>































</li>































</ul>
<p style="margin-left: 60px">1.id选择器(&nbsp;#&nbsp;myid)<br>2.类选择器(.myclassname)<br>3.标签选择器(div,&nbsp;h1,&nbsp;p)<br>4.相邻选择器(h1&nbsp;+&nbsp;p)<br>5.子选择器(ul&nbsp;&gt;&nbsp;li)<br>6.后代选择器(li&nbsp;a)<br>7.通配符选择器(&nbsp;*&nbsp;)<br>8.属性选择器(a)<br>9.伪类选择器(a:&nbsp;hover,&nbsp;li:nth-child)</p>
<p style="margin-left: 60px"><span style="background-color: rgba(255, 255, 0, 1)">可继承的样式</span>:font-size font-family color, text-indent;</p>
<p style="margin-left: 60px"><span style="background-color: rgba(255, 255, 0, 1)">不可继承的样式</span>:border padding margin width height ;</p>
<p style="margin-left: 60px"><span style="background-color: rgba(255, 255, 0, 1)">优先级为</span>: !important&nbsp;&gt;&nbsp;&nbsp;id&nbsp;&gt;&nbsp;class&nbsp;&gt;&nbsp;tag&nbsp; &nbsp; (important&nbsp;比&nbsp;内联优先级高,但内联比&nbsp;id&nbsp;要高)</p>
<p style="margin-left: 60px"><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">CSS3新增伪类举例:</span></p>
<p style="margin-left: 90px"><span style="font-size: 14px">p:first-of-type 选择属于其父元素的首个&nbsp;&lt;p&gt;&nbsp;元素的每个&nbsp;&lt;p&gt;&nbsp;元素。<br>p:last-of-type &nbsp;选择属于其父元素的最后&nbsp;&lt;p&gt;&nbsp;元素的每个&nbsp;&lt;p&gt;&nbsp;元素。<br>p:only-of-type &nbsp;选择属于其父元素唯一的&nbsp;&lt;p&gt;&nbsp;元素的每个&nbsp;&lt;p&gt;&nbsp;元素。<br>p:only-child &nbsp;&nbsp;&nbsp;选择属于其父元素的唯一子元素的每个&nbsp;&lt;p&gt;&nbsp;元素。<br>p:nth-child(2)&nbsp;&nbsp;选择属于其父元素的第二个子元素的每个&nbsp;&lt;p&gt;&nbsp;元素。<br>:enabled &nbsp;:disabled 控制表单控件的禁用状态。<br>:checked &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;单选框或复选框被选中。</span></p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>position的值, relative和absolute分别是相对于谁进行定位的?</strong></span></h3>































</li>































</ul>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">absolute</span>&nbsp;<br>&nbsp; &nbsp; &nbsp;生成绝对定位的元素,&nbsp;相对于最近一级的&nbsp;定位不是 static 的父元素来进行定位。<br><span style="background-color: rgba(255, 255, 0, 1)">fixed</span>&nbsp;(老IE不支持)<br>&nbsp;&nbsp;&nbsp;&nbsp;生成绝对定位的元素,相对于浏览器窗口进行定位。&nbsp;<br><span style="background-color: rgba(255, 255, 0, 1)">relative</span>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;生成相对定位的元素,相对于其在普通流中的位置进行定位。&nbsp;<br><span style="background-color: rgba(255, 255, 0, 1)">static</span> &nbsp;默认值。没有定位,元素出现在正常的流中</p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">CSS3有哪些新特性?</span></strong></span></h3>
</li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px"><strong>https://www.runoob.com/css3/css3-tutorial.html</strong></span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">CSS3实现<span style="background-color: rgba(255, 255, 0, 1)">圆角</span>(border-radius),<span style="background-color: rgba(255, 255, 0, 1)">阴影</span>(box-shadow),<br>对<span style="background-color: rgba(255, 255, 0, 1)">文字加特效</span>(text-shadow、),<span style="background-color: rgba(255, 255, 0, 1)">线性渐变</span>(gradient),<span style="background-color: rgba(255, 255, 0, 1)">旋转</span>(transform)<br>transform:<span style="background-color: rgba(255, 204, 153, 1)">rotate</span>(9deg)&nbsp;<span style="background-color: rgba(255, 204, 153, 1)">scale</span>(0.85,0.90)&nbsp;<span style="background-color: rgba(255, 204, 153, 1)">translate</span>(0px,-30px)&nbsp;<span style="background-color: rgba(255, 204, 153, 1)">skew</span>(-9deg,0deg);//<span style="background-color: rgba(255, 204, 153, 1)">旋转,缩放,定位,倾斜</span><br>增加了更多的CSS选择器&nbsp;&nbsp;<span style="background-color: rgba(255, 255, 0, 1)">多背景</span>&nbsp;rgba&nbsp;<br>在CSS3中唯一引入的<span style="background-color: rgba(255, 255, 0, 1)">伪元素</span>是::selection.<br>媒体查询,多栏布局<br><span style="background-color: rgba(255, 255, 0, 1)">border-image</span></span></p>
<ul>
<li>
<h3 data-tool="mdnice编辑器"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">对BFC规范的理解?</span></h3>






























</li>






























</ul>
<pre><span style="font-size: 14px; font-family: arial, helvetica, sans-serif" lang="EN-US">BFC是块级格式化上下文,他是页面中相对独立的一块渲染区域,他决定了内部的子元素如何进行摆放和定位,以及区域内部元素和区域外部元素之间的相互关系。</span></pre>
<p style="margin-left: 30px"><span style="font-size: 14px; font-family: arial, helvetica, sans-serif">&nbsp;<span style="background-color: rgba(255, 255, 0, 1)">特点</span><span lang="EN-US">1.bfc可以包含浮动元素 </span></span></p>
<p style="margin-left: 30px"><span style="font-size: 14px; font-family: arial, helvetica, sans-serif" lang="EN-US">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.bfc所确定的区域不会与外部浮动元素发生重叠</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px; font-family: arial, helvetica, sans-serif" lang="EN-US">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3.位于同一<span lang="EN-US">bfc下的相邻块级子元素在垂直方向上发生<span lang="EN-US">margin重叠</span></span></span></p>
<p style="margin-left: 30px"><span style="font-size: 14px; font-family: arial, helvetica, sans-serif">&nbsp; <span style="background-color: rgba(255, 255, 0, 1)">如何创建</span><span lang="EN-US"><span style="background-color: rgba(255, 255, 0, 1)">bfc</span> :float值不为<span lang="EN-US">none,overflow值为<span lang="EN-US">auto,display值为<span lang="EN-US">inline-block,position值为<span lang="EN-US">flex或<span lang="EN-US">absolute</span></span></span></span></span></span></span></p>
<ul>
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">常见兼容性问题?</span></strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">*&nbsp;png24位的图片在iE6浏览器上出现背景,解决方案是做成PNG8.也可以引用一段脚本处理.<br><br>*&nbsp;浏览器默认的margin和padding不同。解决方案是加一个全局的*{margin:0;padding:0;}来统一。<br><br>*&nbsp;IE6双边距bug:块属性标签float后,又有横行的margin情况下,在ie6显示margin比设置的大。&nbsp;<br><br>*&nbsp;浮动ie产生的双倍距离(IE6双边距问题:在IE6下,如果对元素设置了浮动,同时又设置了margin-left或margin-right,margin值会加倍。)<br>&nbsp;&nbsp;#box{&nbsp;float:left;&nbsp;width:10px;&nbsp;margin:0&nbsp;0&nbsp;0&nbsp;100px;}&nbsp;<br><br>&nbsp;这种情况之下IE会产生20px的距离,解决方案是在float的标签样式控制中加入&nbsp;——_display:inline;将其转化为行内属性。(_这个符号只有ie6会识别)<br><br>*&nbsp;&nbsp;渐进识别的方式,从总体中逐渐排除局部。&nbsp;<br><br>&nbsp;&nbsp;首先,巧妙的使用“\9”这一标记,将IE游览器从所有情况中分离出来。&nbsp;<br>&nbsp;&nbsp;接着,再次使用“+”将IE8和IE7、IE6分离开来,这样IE8已经独立识别。<br><br>&nbsp;&nbsp;css<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.bb{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-color:#f1ee18;/*所有识别*/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.background-color:#00deff\9;&nbsp;/*IE6、7、8识别*/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+background-color:#a200ff;/*IE6、7识别*/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_background-color:#1e0bd1;/*IE6识别*/&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br><br>*&nbsp;&nbsp;IE下,可以使用获取常规属性的方法来获取自定义属性,<br>&nbsp;&nbsp;&nbsp;也可以使用getAttribute()获取自定义属性;<br>&nbsp;&nbsp;&nbsp;Firefox下,只能使用getAttribute()获取自定义属性.&nbsp;<br>&nbsp;&nbsp;&nbsp;解决方法:统一通过getAttribute()获取自定义属性.<br><br>*&nbsp;IE下,event对象有x,y属性,但是没有pageX,pageY属性;&nbsp;<br>&nbsp;&nbsp;Firefox下,event对象有pageX,pageY属性,但是没有x,y属性.<br><br>*&nbsp;解决方法:(条件注释)缺点是在IE浏览器下可能会增加额外的HTTP请求数。<br><br>*&nbsp;Chrome&nbsp;中文界面下默认会将小于&nbsp;12px&nbsp;的文本强制按照&nbsp;12px&nbsp;显示,&nbsp;<br>&nbsp;&nbsp;可通过加入&nbsp;CSS&nbsp;属性&nbsp;-webkit-text-size-adjust:&nbsp;none;&nbsp;解决.<br><br>*&nbsp;超链接访问过后hover样式就不出现了&nbsp;被点击访问过的超链接样式不在具有hover和active了解决方法是改变CSS属性的排列顺序:<br>L-V-H-A&nbsp;:&nbsp;&nbsp;a:link&nbsp;{}&nbsp;a:visited&nbsp;{}&nbsp;a:hover&nbsp;{}&nbsp;a:active&nbsp;{}<br><br>*&nbsp;怪异模式问题:漏写DTD声明,Firefox仍然会按照标准模式来解析网页,但在IE中会触发怪异模式。为避免怪异模式给我们带来不必要的麻烦,最好养成书写DTD声明的好习惯。现在可以使用(http://www.w3.org/TR/html5/single-page.html)推荐的写法:`&lt;doctype html&gt;`<br><br>*&nbsp;上下margin重合问题<br>ie和ff都存在,相邻的两个div的margin-left和margin-right不会重合,但是margin-top和margin-bottom却会发生重合。<br>解决方法,养成良好的代码编写习惯,同时采用margin-top或者同时采用margin-bottom。<br>*&nbsp;ie6对png图片格式支持不好(引用一段脚本处理)</span></p>
<ul>
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">清除浮动有哪些方法?</span></strong></span></li>






























</ul>
<pre><span style="font-size: 14px"> 浮动元素脱离文档流,不占据空间。浮动元素碰到包含它的边框或者浮动元素的边框停留。</span></pre>
<p style="margin-left: 30px"><span style="font-size: 14px">1.<span style="background-color: rgba(255, 255, 0, 1)">使用空标签清除浮动</span>。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"> &nbsp; 这种方法是在所有浮动标签后面添加一个空标签 定义css clear:both. 弊端就是增加了无意义标签。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">2.<span style="background-color: rgba(255, 255, 0, 1)">使用overflow</span>。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"> &nbsp; 给包含浮动元素的父标签添加css属性 overflow:auto; zoom:1; zoom:1用于兼容IE6。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">3.<span style="background-color: rgba(255, 255, 0, 1)">使用after伪对象清除浮动</span>。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">&nbsp;&nbsp; 该方法只适用于非IE浏览器。具体写法可参照以下示例。使用中需注意以下几点。一、该方法中必须为需要清除浮动元素的伪对象中设置 height:0,否则该元素会比实际高出若干像素;</span></p>
<p style="margin-left: 30px">.clearfix:after;{</p>
<p style="margin-left: 60px">content:"";</p>
<p style="margin-left: 60px">display:block;</p>
<p style="margin-left: 60px">height:0;</p>
<p style="margin-left: 60px">clear:both;</p>
<p style="margin-left: 60px">visibility:hidden;</p>
<p style="margin-left: 30px"><span style="font-size: 14px">&nbsp;}</span></p>
<ul>
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">实现两栏布局的方式?</span></strong><span style="font-size: 16px">(假设左侧宽200,右侧自适应-)</span></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">1.使用浮动</span>:左侧盒子使用浮动float: left;右侧盒子使用margin-left:200px</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">2.使用定位</span>:absolute+margin</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">3.使用flex</span>: 大盒子flex&nbsp; 右盒子flex设成1</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">4.使用浮动+BFC</span>:左盒子使用float:left&nbsp; 右盒子设置overflow: hidden(float+BFC)</span></p>
<ul>
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">实现三列布局的方式?</span></strong><span style="font-size: 16px"><span style="font-size: 15px">(</span></span><span style="font-size: 15px">假设高度已知,请写出三栏布局,其中左右宽度各为300px,中间自适应)</span></span></li>
</ul>
<p style="margin-left: 30px">&lt;div class="box1"&gt;<br>                          &lt;div class="left1"&gt;&lt;/div&gt;<br>                          &lt;div class="right1"&gt;&lt;/div&gt;<br>                          &lt;div class="center1"&gt;&lt;/div&gt;<br>                &lt;/div&gt;</p>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">1.利用浮动</span>:</span><span style="font-size: 14px">左右盒子float left和right&nbsp; center设置margin-left:300px和margin-right:300px</span></p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)"><span style="font-size: 14px">2.</span>利用绝对定位</span>:左右盒子设置绝对定位absolute left:0 right:0 top:0,center设置margin-left:300px和margin-ringht:300px</p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">3.利用弹性布局felx</span>:大盒子box1设置display:felx ,center盒子设置felx:1</p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">4.利用display:table布局</span>:大盒子设置display:table ,left和right盒子设置display:table-cell</p>
<ul>
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">垂直水平居中?</span></strong></span></li>




























</ul>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">1.</span>水平居中:给div设置一个宽度,然后添加margin:0 auto属性</p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">2.</span>把元素变成定位元素position:absolute;</p>
<p style="margin-left: 60px">设置元素的定位位置,距离上、下、左、右都为0</p>
<p style="margin-left: 60px">left:0;</p>
<p style="margin-left: 60px">right:0;</p>
<p style="margin-left: 60px">top:0;</p>
<p style="margin-left: 60px">bottom:0;</p>
<p style="margin-left: 60px">margin:auto;</p>
<p style="margin-left: 60px"><span style="color: rgba(255, 0, 0, 1)">*兼容性较好,缺点:不支持IE7以下的浏览器</span></p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">3.</span>把元素变成定位元素position:absolute;</p>
<p style="margin-left: 30px">  设置元素的定位位置,距离上、左都为50%</p>
<p style="margin-left: 60px">left:50%;</p>
<p style="margin-left: 60px">top:50%;</p>
<p style="margin-left: 60px">设置元素的左外边距、上外边距为宽高的负1/2</p>
<p style="margin-left: 60px">margin-left:-100px;</p>
<p style="margin-left: 60px">margin-top:-200px;</p>
<p style="margin-left: 60px">}</p>
<p style="margin-left: 60px"><span style="color: rgba(255, 0, 0, 1)">*兼容性好;缺点:必须知道元素的宽高</span></p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">4.</span>把元素变成定位元素position:absolute;</p>
<p style="margin-left: 60px">设置元素的定位位置,距离上、左都为50%</p>
<p style="margin-left: 60px">left:50%;</p>
<p style="margin-left: 60px">top:50%;</p>
<p style="margin-left: 60px">设置元素的相对于自身的偏移度为负50%(也就是元素自身尺寸的一半)</p>
<p style="margin-left: 60px">transform:translate(-50%,-50%);</p>
<p style="margin-left: 60px"><span style="color: rgba(255, 0, 0, 1)">*这是css3里的样式;缺点:兼容性不好,只支持IE9+的浏览器</span></p>
<p style="margin-left: 30px"><span style="background-color: rgba(255, 255, 0, 1)">5.</span>利用flex布局</p>
<p style="margin-left: 30px">  父盒子设置display:flex;<code class="language-text hljs plaintext"><br></code></p>
<p style="margin-left: 30px">  align-items:center;/*垂直居中*/</p>
<p style="margin-left: 30px">  justify-content:contenr/*水平居中*/</p>
<p style="margin-left: 30px"><strong><span style="color: rgba(128, 0, 0, 1); font-size: 16px">三角样式</span></strong></p>
<p style="margin-left: 30px"><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210509194540298-6427664.png"></p>
<h4><strong><span style="font-size: 18pt">JavaScript 基础</span></strong></h4>
<ul>
<li><span style="font-size: 16px"><strong><span style="color: rgba(128, 0, 0, 1)">问题1、前++、后++、区别</span></strong></span></li>


















</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">var i=2 ;</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">a = i++ //将i的值赋给a , 即a = i,之后再执行i = i + 1;&nbsp; &nbsp;2</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">a = ++i //将i+1 的值赋给a,即a = i + 1 ,之后再执行i = i + 1;&nbsp; &nbsp;3</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">  console.log(a)</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">【总结】:</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">前++是先自加后计算、后++是后自加先计算</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">1:前置++ 是将自身+1 后的值赋给变量,同时自身加1;</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">&nbsp;2:后置++ 是将自身的值赋给变量,之后自身再加1;</span></p>
<ul class="list-paddingleft-2" data-mark="-">
<li><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">JS 有哪些数据类型?</span></strong></span></li>



























</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">Js常用数据类型undefined&nbsp;&nbsp;null&nbsp;&nbsp;boolean&nbsp;&nbsp;number&nbsp;&nbsp;string<br>
Js引用类型object&nbsp;&nbsp;Array function</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">ES6基本数据类型多了个symblo</span></p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>js判断类型</strong></span></li>



























</ul>
<p style="margin-left: 30px"><span style="font-size: 14px; font-family: arial, helvetica, sans-serif; background-color: rgba(255, 255, 0, 1)">1、typeof</span><br><span style="font-family: arial, helvetica, sans-serif"><span style="font-size: 14px">检测不出null 和 数组,结果都为object,所以typeof常用于检测基本类型<br><span style="background-color: rgba(255, 255, 0, 1)">2、</span></span><span style="background-color: rgba(255, 255, 0, 1)">instanceof</span></span><br><span style="font-family: arial, helvetica, sans-serif">不能检测出number、boolean、string、undefined、null、symbol类型,所以instancof常用于检测复杂类型以及级成关系</span><br><span style="font-family: arial, helvetica, sans-serif; background-color: rgba(255, 255, 0, 1)">3、constructor</span><br><span style="font-family: arial, helvetica, sans-serif">null、undefined没有construstor方法,因此constructor不能判断undefined和null。但是contructor的指向是可以被改变,所以不安全</span><br><span style="font-family: arial, helvetica, sans-serif; background-color: rgba(255, 255, 0, 1)">4、Object.prototype.toString.call</span><br><span style="font-family: arial, helvetica, sans-serif">全类型都可以判断</span></p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong><strong style="margin: 0; padding: 0; font-family: &quot;Helvetica Neue&quot;, Helvetica, Verdana, Arial, sans-serif">数据类型怎么检测</strong></strong></span></li>



















</ul>
<div class="cnblogs_code">
<pre>1、<span style="color: rgba(0, 0, 255, 1)">typeof</span><span style="color: rgba(0, 0, 0, 1)">
例:console.log(</span><span style="color: rgba(0, 0, 255, 1)">typeof</span> <span style="color: rgba(0, 0, 255, 1)">true</span>) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> boolean</span>

2、<span style="color: rgba(0, 0, 255, 1)">instanceof</span><span style="color: rgba(0, 0, 0, 1)">
例:console.log([</span>1,2] <span style="color: rgba(0, 0, 255, 1)">instanceof</span> Array) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> true</span>

3<span style="color: rgba(0, 0, 0, 1)">、constructor
例: console.log([</span>1, 2].constructor === Array) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> ture</span>

4<span style="color: rgba(0, 0, 0, 1)">、Object.prototype.toString.call
例:Object.prototype.toString.call([</span>1, 2]) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> </span></pre>
</div>
<pre></pre>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>Js数组的方法</strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 16px"><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">join()<span style="color: rgba(34, 34, 34, 1); letter-spacing: 0.25575px; background-color: rgba(255, 255, 255, 0.9)">数组转换成字符串</span></span><br><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">
push()</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">尾部添加</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US"><br>
</span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US">pop()尾部删除<br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">shift() 头部</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">删除</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US"><br></span><span lang="EN-US">unshift() 头部添加<br>
sort()</span>排序<span lang="EN-US"><br>
reverse()</span>反转<span lang="EN-US"><br>
concat()</span>链接两个或多个数组<span lang="EN-US"><br>
slice()</span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US"><br></span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US"><span style="margin: 0; padding: 0; line-height: 1.5">  var arr=</span><br>  console.log(arr.slice(1))&nbsp;<span style="color: rgba(0, 128, 0, 1)">//选择序列号从1到最后的所有元素组成的新数组</span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US"><br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US">  console.log(arr.slice(1,3)) <span style="color: rgba(0, 128, 0, 1)">//不包含序列号,序号为3的元素</span><br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US">splice()<br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US">  splice(index,howmany,item1,...itemx)<br>  index参数:必须,整数,规定添加或删除的位置,使用负数,从数组尾部规定位置</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US"><br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">  howmany参数:必须,要删除的数量,如果为0则不删除项目</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US"><br>
  item1,...itemx参数:可选,向数组添加的新项目</span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US"><br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US">  var arr=<br></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US">  console.log(arr.splice(2,1,"hello"));<span style="color: rgba(0, 128, 0, 1)">//返回的新数组</span><br></span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px" lang="EN-US">  console.log(arr);<span style="color: rgba(0, 128, 0, 1)">//</span></span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US"><br>indexOf()</span>和<span lang="EN-US">&nbsp;lastIndexOf()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span lang="EN-US"><br>
forEach()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)<span lang="EN-US"><br>
map()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)<span lang="EN-US"><br>
filter()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)<span lang="EN-US"><br>
every()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)<span lang="EN-US"><br>
some()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)<span lang="EN-US"><br>
reduce()</span>和<span lang="EN-US">&nbsp;reduceRight()&nbsp;</span>(<span lang="EN-US">ES5</span>新增)</span></span></p>
<ul>
<li>
<h4 style="margin-top: 10px; margin-right: 0; margin-bottom: 10px; padding-top: 0; padding-right: 0; padding-bottom: 0; font-size: 14px; font-family: verdana, Arial, Helvetica, sans-serif"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">JS中的Array.splice()和Array.slice()方法有什么区别</span></h4>






















</li>






















</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">话不多说,来看第一个例子:</span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">var arr=;//设置一个数组
console.log(arr.slice(2,7));//2,3,4,5,6
console.log(arr.splice(2,7));//2,3,4,5,6,7,8
//由此我们简单推测数量两个函数参数的意义,
slice(start,end)第一个参数表示开始位置,第二个表示截取到的位置(不包含该位置)
splice(start,length)第一个参数开始位置,第二个参数截取长度
</pre>
</div>
<p>  <span style="color: rgba(51, 51, 51, 1); font-family: verdana, Arial, Helvetica, sans-serif">接着看第二个:</span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">var x=y=
console.log(x.slice(2,5));//2,3,4
console.log(x);原数组并未改变
//接下来用同样方式测试splice
console.log(y.splice(2,5));//2,3,4,5,6
console.log(y);//显示原数组中的数值被剔除掉了
</pre>
</div>
<p>  <span style="color: rgba(51, 51, 51, 1); font-family: verdana, Arial, Helvetica, sans-serif">slice和splice虽然都是对于数组对象进行截取,但是二者还是存在明显区别,函数参数上slice和splice第一个参数都是截取开始位置,slice第二个参数是截取的结束位置(不包含),而splice第二个参数(表示这个从开始位置截取的长度),slice不会对原数组产生变化,而splice会直接剔除原数组中的截取数据!</span></p>
<p><span style="color: rgba(51, 51, 51, 1); font-family: verdana, Arial, Helvetica, sans-serif">  <span style="color: rgba(255, 0, 0, 1)">slice不会改变原数组,</span></span><span style="font-family: verdana, Arial, Helvetica, sans-serif; color: rgba(255, 0, 0, 1)">splice会改变原数组</span></p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>数值转换</strong></span></li>
</ul>
<p style="margin-left: 30px">JSON.parse() 转json对象<br>JSON.stringify()   转json字符串<br>String(),toString() 转字符串类型<br>NumberparseInt()字符串转数值类型<br>split            字符串转数组<br>join               数组转字符串</p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>什么是跨域,常见跨域</strong></span></li>

























</ul>
<p style="margin-left: 30px"><span style="font-size: 16px"><span style="font-size: 14px">由于浏览器获取数据遵循同源策略,所以当访问非同源资源的时候,就需要跨域,常见的跨域方式有jsonp,a img src cors</span><br><span style="font-size: 14px">
同源策略:同协议,端口,域名的安全策略</span><strong><br></strong></span></p>
<p style="margin-left: 30px"><span style="font-size: 16px"><strong><span style="font-size: 16px"><strong>jsonp原理</strong></span><br>
</strong><span style="font-size: 14px">动态创建script标签,利用callpack回调函数获取值</span><br><span style="font-size: 14px">
function&nbsp;callbackFunction(){</span><br><span style="font-size: 14px">
  alert("回滚");</span><br><span style="font-size: 14px">
}</span><br><span style="font-size: 14px">
var script=document.createElement("script");</span><br><span style="font-size: 14px">
script.src="http://frergeoip.net.json/?callback=callbackFunction";<strong><br></strong></span></span></p>
<p style="margin-left: 30px"><span style="font-size: 16px"><span style="font-size: 14px"><span style="font-size: 16px"><strong>CORS的原理:</strong></span><br>当传输数据量比较大,get形式搞不定的时候,可以用到cors跨域,cors原理是定义一种跨域访问的机制,可以让ajax实现跨域访问。Cors允许一个域上的网络应用向另一个域提交跨域ajax请求。实现此功能非常简单,只需由服务器发送一个响应标头即可。<br>
Jsonp是get形式,承载的信息量有限,所以信息量较大的时cors是不二选择。</span></span></p>
<p style="margin-left: 30px" align="left"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>http</strong><strong>协议:</strong></span><br>
http协议是定义服务器端和客户端之间文件传输的沟通方式<br>
请求服务器上的资源,请求html&nbsp;css&nbsp;js&nbsp;图片文件等&nbsp;&nbsp;<br>
请求方法(所有方法全为大写)有多种,各个方法的解释如下:<br>
GET&nbsp;(get)&nbsp;&nbsp;&nbsp;&nbsp;请求获取Request-URI所标识的资源&nbsp; <span style="color: rgba(255, 0, 0, 1)">&nbsp;--获取资源</span><br>
POST&nbsp;(post)&nbsp;&nbsp;&nbsp;在Request-URI所标识的资源后附加新的数据 <span style="color: rgba(255, 0, 0, 1)">---传输资源</span><br>
HEAD&nbsp;(head)&nbsp;&nbsp;&nbsp;请求获取由Request-URI所标识的资源的响应消息报头&nbsp; <span style="color: rgba(255, 0, 0, 1)">---获取报文首部</span><br>
PUT&nbsp;(put)&nbsp;&nbsp;&nbsp;&nbsp;请求服务器存储一个资源,并用Request-URI作为其标识&nbsp; <span style="color: rgba(255, 0, 0, 1)">---更新资源</span><br>
DELETE&nbsp;(delete)&nbsp;请求服务器删除Request-URI所标识的资源&nbsp; <span style="color: rgba(255, 0, 0, 1)">---删除资源</span><br>
TRACE&nbsp;(trace)&nbsp;&nbsp;请求服务器回送收到的请求信息,主要用于测试或诊断<br>
CONNECT(connect)&nbsp;保留将来使用<br>
OPTIONS(options)&nbsp;请求查询服务器的性能,或者查询与资源相关的选项和需求<br>
常见状态码:<br>
200&nbsp;请求成功<br>
301&nbsp;&nbsp;资源(网页等)被永久转移到其他url<br>
404&nbsp;请求的资源不存在<br>
500&nbsp;内部服务器错误</p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>说说你对闭包的理解</strong></span></li>
























</ul>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 12pt; font-family: 黑体; color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="font-family: arial, helvetica, sans-serif; font-size: 14px">使用闭包主要是为了设计私有的方法和变量。闭包的优点是可以避免全局变量的污染,缺点是闭包会常驻内存,会增大内存使用量,使用不当很容易造成内存泄露。</span></span></p>
<p style="margin: 0 0 0.0001pt 30px; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><strong><span style="color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">闭包有三个特性:</span></strong></span></p>
<p style="margin: 0 0 0.0001pt 30px; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="font-family: 黑体; mso-bidi-font-family: 黑体; color: rgba(62, 62, 62, 1)" lang="EN-US"> &nbsp;</span><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span style="text-indent: 0; color: rgba(62, 62, 62, 1)" lang="EN-US">1.</span><span style="text-indent: 0; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgba(62, 62, 62, 1)">函数嵌套函数</span></span></p>
<p style="margin: 0 36pt 0.0001pt 0; mso-pagination: widow-orphan"><span style="font-family: arial, helvetica, sans-serif; font-size: 14px"><span style="color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   2.</span><span style="color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">函数内部可以引用外部的参数和变量 </span></span></p>
<p style="margin: 0 36pt 0.0001pt 0; mso-pagination: widow-orphan"><span style="font-family: arial, helvetica, sans-serif"><span style="color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; font-size: 14px" lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   3.</span><span style="color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="font-size: 14px">参数和变量不会被垃圾回收机制回收</span></span></span></p>
<p class="MsoNormal" style="margin-left: 30px" align="left"><strong><span style="font-size: 12pt; font-family: 黑体; color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">闭包用途</span></strong><span style="font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt" lang="EN-US"><br>
<span style="background-color: rgba(255, 255, 0, 1); font-size: 14px">1</span></span><span style="font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">缓存</span><span lang="EN-US"><br>
</span>设想我们有一个处理过程很耗时的函数对象,每次调用都会花费很长时间,那么我们就需要将计算出来的值存储起来,当调用这个函数的时候,首先在缓存中查找,如果找不到,则进行计算,然后更新缓存并返回值,如果找到了,直接返回查找到的值即可。闭包正是可以做到这一点,因为它不会释放外部的引用,从而函数内部的值可以得以保留。<span lang="EN-US"><br>
<span style="background-color: rgba(255, 255, 0, 1)">2&nbsp;</span></span><span style="background-color: rgba(255, 255, 0, 1)">实现封装</span><span lang="EN-US"><br>
</span>可以先来看一个关于封装的例子,在<span lang="EN-US">person</span>之外的地方无法访问其内部的变量,而通过提供闭包的形式来访问:</span><span lang="EN-US"><br><span style="font-size: 14px">
var&nbsp;person&nbsp;=&nbsp;function(){&nbsp;&nbsp;&nbsp;&nbsp;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 14px">//</span></span><span style="font-size: 14px">变量作用域为函数内部,外部无法访问<span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;name&nbsp;=&nbsp;"default";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getName&nbsp;:&nbsp;function(){&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;name;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setName&nbsp;:&nbsp;function(newName){&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;=&nbsp;newName;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br>
}();&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
print(person.name);//</span>直接访问,结果为</span><span lang="EN-US"><span style="font-size: 14px">undefined&nbsp;&nbsp;&nbsp;&nbsp;</span><br><span style="font-size: 14px">
print(person.getName());&nbsp;&nbsp;&nbsp;&nbsp;</span><br><span style="font-size: 14px">
person.setName("abruzzi");&nbsp;&nbsp;&nbsp;&nbsp;</span><br><span style="font-size: 14px">
print(person.getName());&nbsp; &nbsp;</span></span></span></p>
<ul>
<li>
<h3><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">如何阻止事件冒泡?</span></h3>





















</li>





















</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">ie:阻止冒泡ev.cancelBubble = true;非IE ev.stopPropagation();</span></p>
<ul>
<li>
<h3><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">如何阻止默认事件?</span></h3>





















</li>





















</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">(1)return false;(2) ev.preventDefault();</span></p>
<ul>
<li>
<h3><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">添加 删除 替换 插入到某个节点的方法?</span></h3>





















</li>





















</ul>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">1)创建新节点
createElement() //创建一个具体的元素
createTextNode() //创建一个文本节点

2)添加、移除、替换、插入
appendChild() //添加
removeChild() //移除
replaceChild() //替换
insertBefore() //插入

3)查找
getElementsByTagName() //通过标签名称
getElementsByName() //通过元素的Name属性的值
getElementById() //通过元素Id,唯一性</pre>
</div>
<ul>
<li>
<h3><span style="color: rgba(128, 0, 0, 1)">document load 和document ready的区别?</span></h3>
</li>
</ul>
<p style="margin-left: 30px">document.onload 是在结构和样式,外部js以及图片加载完才执行js<br>document.ready是dom树创建完成就执行的方法,原生种没有这个方法,jquery中有 $().ready(function)</p>
<ul>
<li>
<h3><span style="color: rgba(128, 0, 0, 1)">Javascript的事件流模型都有什么?</span></h3>





















</li>





















</ul>
<p style="margin-left: 30px">“事件捕捉”:是从上往下,<span style="font-family: arial, helvetica, sans-serif">window,document,document.<span style="font-size: 12pt" lang="EN-US">documentelment</span><span style="font-size: 14px">(获取的<span lang="EN-US">html</span>)</span><span style="font-size: 12pt" lang="EN-US"> document,body </span><span style="font-size: 12pt">、</span><span style="font-size: 14px"><span lang="EN-US">……..</span>目标元素</span></span></p>
<p style="margin-left: 30px">“事件冒泡”:<span style="font-family: arial, helvetica, sans-serif; font-size: 14px">是从下往上:反之</span></p>
<p style="margin-left: 30px">“DOM事件流”:三个阶段:事件捕捉、目标阶段、事件冒泡</p>
<p style="margin-left: 30px"><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210509200851537-383978727.png"></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px"><strong><span style="font-size: 16px"><span lang="EN-US">Dom</span><span style="font-family: 宋体">事件类:</span></span></strong></span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">Dom0&nbsp; element.onclick=function(){}</span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">DOM2
element.addEventlistener(‘click’,function(){},flase)</span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">DOM3
element.addEventlistener(‘keyup’,function(){},flase)</span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px"><span lang="EN-US">Event.preventdefault()&nbsp; </span><span style="font-family: 宋体">阻止默认事件</span></span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px"><span lang="EN-US">Event.stoppropagation()&nbsp; </span><span style="font-family: 宋体">阻止冒泡</span></span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px"><span lang="EN-US">Event.currenTtarget()</span><span style="font-family: 宋体">事件代理</span></span>&nbsp;</p>
<p class="MsoNormal" style="margin-left: 30px"><span style="font-size: 14px"><span lang="EN-US">Event.target </span><span style="font-family: 宋体">当前被点击元素</span></span></p>
<ul>
<li>
<h2 style="margin-top: 0; margin-right: 0; margin-bottom: 0.0001pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="font-size: 16px; font-family: arial, helvetica, sans-serif; color: rgba(128, 0, 0, 1)"><strong><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" lang="EN-US">null</span></strong><strong><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">和<span lang="EN-US">undefined</span>的区别?</span></strong></span></h2>





















</li>





















</ul>
<p style="margin: 0 0 0.0001pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="font-family: 黑体; color: rgba(62, 62, 62, 1); background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" lang="EN-US">  &nbsp; <span style="color: rgba(0, 0, 0, 1); font-size: 14px; font-family: arial, helvetica, sans-serif">&nbsp;null</span></span><span style="color: rgba(0, 0, 0, 1); font-size: 14px; font-family: arial, helvetica, sans-serif"><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">是一个表示<span lang="EN-US">"</span>无<span lang="EN-US">"</span>的对象,转为数值时为<span lang="EN-US">0</span>;<span lang="EN-US">undefined</span>是一个表示<span lang="EN-US">"</span>无<span lang="EN-US">"</span>的原始值,转为数值时为<span lang="EN-US">NaN</span>。</span></span></p>
<p class="MsoNormal" style="margin-left: 30px" align="left"><span style="color: rgba(0, 0, 0, 1); font-size: 14px; font-family: arial, helvetica, sans-serif">&nbsp; 当声明的变量还未被初始化时,变量的默认值为<span lang="EN-US">undefined</span>。<span lang="EN-US"> null</span>用来表示尚未存在的对象,常用来表示函数企图返回一个不存在的对象。</span><span style="font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><span lang="EN-US"><span style="font-size: 14px">&nbsp;</span></span></span></p>
<ul>
<li>
<h2 style="margin-top: 0; margin-right: 0; margin-bottom: 0.0001pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial"><span style="color: rgba(128, 0, 0, 1); font-family: arial, helvetica, sans-serif; font-size: 16px"><strong><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" lang="EN-US">js</span></strong><strong><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">延迟加载的方式有哪些?</span></strong></span></h2>
























</li>
























</ul>
<pre><span style="font-family: arial, helvetica, sans-serif; font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" lang="EN-US">defer</span><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">和<span lang="EN-US">async</span>、动态创建<span lang="EN-US">DOM</span>方式(创建<span lang="EN-US">script</span>,插入到<span lang="EN-US">DOM</span>中,加载完毕后<span lang="EN-US">callBack</span>)、按需异步载入<span lang="EN-US">js</span></span></span></pre>
<ul>
<li>
<h2><span style="font-family: arial, helvetica, sans-serif; font-size: 16px; color: rgba(128, 0, 0, 1)"><strong><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial" lang="EN-US">call() </span></strong><strong><span style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial">和<span lang="EN-US"> .apply() </span>的区别和作用?</span></strong></span></h2>
</li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">相同点:两个方法产生的作用是完全一样的,都是改变this指向的</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">不同点:方法传递的参数不同</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">Object.call(this,obj1,obj2,obj3)</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">Object.apply(this,arguments)</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">Apply()接收两个参数,一个是函数运行的作用域(<span lang="EN-US">this),另一个是参数数组。</span></span></p>
<p class="_mce_tagged_br" style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US">Call()方法的第一个参数与<span lang="EN-US">apply()相同,但传递的参数必须列举出来。</span></span></p>
<ul>
<li>
<h2 class="_mce_tagged_br"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)" lang="EN-US"><span lang="EN-US"><strong>mvc和mvvm模式原理:</strong></span></span></h2>
</li>
</ul>
<p class="_mce_tagged_br" style="margin-left: 30px"><span style="font-size: 14px" lang="EN-US"><span lang="EN-US"><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210511125251629-841222770.png"></span></span></p>
<ul>
<li class="_mce_tagged_br"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)" lang="EN-US"><span lang="EN-US"><strong style="margin: 0; padding: 0; font-family: &quot;Helvetica Neue&quot;, Helvetica, Verdana, Arial, sans-serif; font-size: 16px">JS为什么要区分微任务和宏任务?</strong></span></span></li>
</ul>
<pre><span style="margin: 0; padding: 0; line-height: 1.5 !important; font-size: 14px">(1)js是单线程的,但是分同步异步
(2)微任务和宏任务皆为异步任务,它们都属于一个队列
(3)宏任务一般是:script,setTimeout,setInterval、setImmediate
(4)微任务:原生Promise
(5)遇到微任务,先执行微任务,执行完后如果没有微任务,就执行下一个宏任务,如果有微任务,就按顺序一个一个执行微任务</span></pre>
<ul>
<li><strong style="color: rgba(128, 0, 0, 1); font-size: 16px">setTimeout和setInterval</strong></li>
</ul>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">setTimeout是3秒后执行</span>
setTimeout(<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
alert(</span>123<span style="color: rgba(0, 0, 0, 1)">)
},</span>3000<span style="color: rgba(0, 0, 0, 1)">)

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">setInterval是每隔三秒执行一次,不断的重复执行</span>
setInterval(<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
alert(</span>1121222<span style="color: rgba(0, 0, 0, 1)">)
},</span>3000<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">两个执行都是异步进行的</span></pre>
</div>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>深拷贝浅拷贝</strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">深拷贝和浅拷贝最根本的区别在于是否真正获取一个<strong>对象的复制实体</strong>,而不是引用。</span></p>
<p style="margin-left: 30px">假设B复制了A,修改A的时候,看B是否发生变化:</p>
<p style="margin-left: 30px">如果B跟着<strong>也变了</strong>,说明是浅拷贝,拿人手短!(修改堆内存中的同一个值)</p>
<p style="margin-left: 30px">如果B<strong>没有改变</strong>,说明是深拷贝,自食其力!(修改堆内存中的不同的值)</p>
<p style="margin-left: 30px"><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">浅拷贝实现</span><span style="font-size: 14px">:</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">var</span> a = ;
</span><span style="color: rgba(0, 0, 255, 1)">var</span> b =<span style="color: rgba(0, 0, 0, 1)"> a;
a[</span>0] = 2<span style="color: rgba(0, 0, 0, 1)">
console.log(a);</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"></span>
console.log(b);<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">////b会随着a的变化而变化</span></pre>
</div>
<pre><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">深拷贝实现</span>:<br></span></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">var</span> a = [{"name":"weifeng"},{"name":"boy"<span style="color: rgba(0, 0, 0, 1)">}];
</span><span style="color: rgba(0, 0, 255, 1)">var</span> a_copy =[].concat(JSON.parse(JSON.stringify(a)));<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">深拷贝</span>
a_copy.name = "girl"<span style="color: rgba(0, 0, 0, 1)">
console.log(a);</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">[{"name":"weifeng"},{"name":"boy"}]</span>
console.log(a_copy );<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">[{"name":"weifeng"},{"name":"girl"}]</span></pre>
</div>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>重排重绘</strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">回流(重排)</span><span style="font-size: 14px">:</span></p>
<div>
<div style="margin-left: 30px"><span style="font-size: 14px">当render tree中的一部分(或全部)因为元素的规模尺寸,布局,隐藏等改变而需要重新构建。这就称为回流(reflow)。每个页面至少需要一次回流,就是在页面第一次加载的时候,这时候是一定会发生回流的,因为要构建render tree。在回流的时候,浏览器会使渲染树中受到影响的部分失效,并重新构造这部分渲染树,完成回流后,浏览器会重新绘制受影响的部分到屏幕中,该过程成为重绘。</span></div>
</div>
<p style="margin-left: 30px"><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">重绘</span><span style="font-size: 14px">:</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">当render tree中的一些元素需要更新属性,而这些属性只是影响元素的外观,风格,而不会影响布局的,比如background-color。则就叫称为重绘。</span></p>
<div>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="background-color: rgba(255, 255, 0, 1)">区别</span>:</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">回流必将引起重绘,而重绘不一定会引起回流。比如:只有颜色改变的时候就只会发生重绘而不会引起回流</span><br><span style="font-size: 14px">
当页面布局和几何属性改变时就需要回流</span><br><span style="font-size: 14px">
比如:添加或者删除可见的DOM元素,元素位置改变,元素尺寸改变——边距、填充、边框、宽度和高度,内容改变。</span></p>
<ul>
<li><strong><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">防抖和节流?</span></strong></li>


</ul>
<div>
<p style="margin-left: 30px"><span style="font-size: 14px">在前端开发的过程中,我们经常会需要绑定一些持续触发的事件,如 resize、scroll、mousemove&nbsp;keyup 等等,但有些时候我们并不希望在事件持续触发的过程中那么频繁地去执行函数。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">通常这种情况下我们怎么去解决的呢?一般来讲,防抖和节流是比较好的解决方案。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">1、防抖:</span></p>
<div>
<div style="margin-left: 30px"><span style="font-size: 14px">指触发事件后在n秒后函数执行,如果在n秒内又触发了事件,则会重新计算函数执行时间。应用场景(适合多次事件只响应一次的情况):给按钮加防抖函数防止表单多次提交;判断scroll是否滑到底部;对于输入框连续输入进行AJAX验证时,用函数防抖能有效减少请求次数。</span></div>
<div style="margin-left: 30px"><span style="font-size: 14px">现给一个场景:现监听一个输入框,文字变化后触发change事件。若直接用keyup事件,则会频繁触发change事件。加了防抖后,用户输入结束或暂停时,才会触发change事件。</span></div>
<div style="margin-left: 30px"><span style="color: rgba(255, 0, 0, 1)"><strong><span style="font-size: 14px">所谓防抖,就是指触发事件后在 n 秒内函数只能执行一次,如果在 n 秒内又触发了事件,则会重新计算函数执行时间。</span></strong></span></div>
<div style="margin-left: 30px">
<div class="cnblogs_code">
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;Document&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;input type="text" id="input1"&gt;
&lt;/body&gt;
&lt;script&gt;<span style="color: rgba(0, 0, 0, 1)">
    const input1 </span>= document.getElementById('input1'<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">1、不加防抖 ,会一直触发change事件</span>
    input1.addEventListener('keyup', <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
            console.log(input1.value)
    })

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">2、简单实现防抖</span>
    let timer = <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
    input1.addEventListener(</span>'keyup', <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
      </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)">(timer){
            clearTimeout(timer)
      }
      timer </span>= setTimeout(() =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
            </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">模拟触发change事件</span>
<span style="color: rgba(0, 0, 0, 1)">            console.log(input1.value)
            </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">清空定时器</span>
            timer = <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
      }, </span>1000<span style="color: rgba(0, 0, 0, 1)">)
    })

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">3、将防抖函数这个工具进行封装</span>
    <span style="color: rgba(0, 0, 255, 1)">function</span> debounce(fn, delay = 50<span style="color: rgba(0, 0, 0, 1)">){
      </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">timer是闭包中的,不能被别人修改</span>
      let timer = <span style="color: rgba(0, 0, 255, 1)">null</span>
      <span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
            </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)">(timer){
                clearTimeout(timer)
            }
            timer </span>= setTimeout(() =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
                fn.apply(</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">, arguments)
                timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
            }, delay)
      }
    }
    input1.addEventListener(</span>'keyup', debounce(<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
      console.log(input1.value)
    }, </span>600<span style="color: rgba(0, 0, 0, 1)">))
</span>&lt;/script&gt;
&lt;/html&gt;</pre>
</div>
<p>则封装后的防抖函数为:</p>
<div class="cnblogs_code">
<pre>    <span style="color: rgba(0, 0, 255, 1)">function</span> debounce(fn, delay = 50<span style="color: rgba(0, 0, 0, 1)">){
      let timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">timer是闭包中的,不能被别人修改</span>
      <span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
            </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)">(timer){
                clearTimeout(timer)
            }
            timer </span>= setTimeout(() =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
                fn.apply(</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">, arguments)
                timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
            }, delay)
      }
    }</span></pre>
</div>
</div>
</div>
<p style="margin-left: 30px"><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">2、节流:</span></p>
<div>
<div style="margin-left: 30px"><span style="font-size: 14px">连续发送的事件在n秒内只执行一次函数。应用场景(适合大量事件按时间做平均分配触发):DOM元素拖拽;Canvas画笔功能。</span></div>
<div style="margin-left: 30px"><span style="font-size: 14px">现给一个场景:拖拽一个元素,要随时拿到该元素被拖拽的位置。若直接用drag事件,则会频繁触发,很容易导致卡顿。加了节流后,无论拖拽速度多快,都会每隔固定时间触发一次。</span></div>
<div style="margin-left: 30px"><span style="font-size: 14px; color: rgba(255, 0, 0, 1)"><strong>所谓节流,就是指连续触发事件但是在 n 秒中只执行一次函数</strong>。<strong>节流会稀释函数的执行频率。</strong></span></div>
<div style="margin-left: 30px">
<div class="cnblogs_code">
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;Document&lt;/title&gt;
    &lt;style&gt;<span style="color: rgba(0, 0, 0, 1)">
      #div1{
            border: 1px solid #ccc;
            width: 200px;
            height: 100px;
      }
    </span>&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id = "div1" draggable="true"&gt;可拖拽&lt;/div&gt;
    &lt;script&gt;<span style="color: rgba(0, 0, 0, 1)">
      const div1 </span>= document.getElementById('div1'<span style="color: rgba(0, 0, 0, 1)">)

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">1、简单实现节流</span>
      let timer = <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
      div1.addEventListener(</span>'drag', <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(e){
            </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)">(timer){
                </span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)">
            }
            timer </span>= setTimeout(() =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
                console.log(e.offsetX, e.offsetY)
                timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">定时器执行了,才让timer为空</span>
            }, 1000<span style="color: rgba(0, 0, 0, 1)">)            
      })

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">2、将节流函数这个工具进行封装</span>
      <span style="color: rgba(0, 0, 255, 1)">function</span> throttle(fn, delay = 100<span style="color: rgba(0, 0, 0, 1)">){
            let timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span>
            <span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
                </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)">(timer){
                  </span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)">
                }
                timer </span>= setTimeout(() =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
                  fn.apply(</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">, arguments)
                  timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
                },delay)
            }
      }
      div1.addEventListener(</span>'drag', throttle(<span style="color: rgba(0, 0, 255, 1)">function</span>(e){ <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">形参e会传给throttle函数运行后返回的函数</span>
<span style="color: rgba(0, 0, 0, 1)">                console.log(e.offsetX, e.offsetY)   
      },</span>200<span style="color: rgba(0, 0, 0, 1)">))
    </span>&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p>则封装后的节流函数为:</p>
<div class="cnblogs_code">
<pre>      <span style="color: rgba(0, 0, 255, 1)">function</span> throttle(fn, delay = 100<span style="color: rgba(0, 0, 0, 1)">){
            let timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span>
            <span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(){
                </span><span style="color: rgba(0, 0, 255, 1)">if</span><span style="color: rgba(0, 0, 0, 1)">(timer){
                  </span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)">
                }
                timer </span>= setTimeout(() =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
                  fn.apply(</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">, arguments)
                  timer </span>= <span style="color: rgba(0, 0, 255, 1)">null</span><span style="color: rgba(0, 0, 0, 1)">
                },delay)
            }
      }</span></pre>
</div>
</div>
</div>
</div>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>说说你对语义化的理解?</strong></span></li>
</ul>
<pre><span style="font-size: 14px" lang="EN-US">1,去掉或者丢失样式的时候能够让页面呈现出清晰的结构</span></pre>
<pre><span style="font-size: 14px" lang="EN-US">2,有利于<span lang="EN-US">SEO:和搜索引擎建立良好沟通,有助于爬虫抓取更多的有效信息:爬虫依赖于标签来确定上下文和各个关键字的权重;</span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US">3,方便其他设备解析(如屏幕阅读器、盲人阅读器、移动设备)以意义的方式来渲染网页;</span></pre>
<pre><span style="font-size: 14px" lang="EN-US">4,便于团队开发和维护,语义化更具可读性,是下一步吧网页的重要动向,遵循<span lang="EN-US">W3C标准的团队都遵循这个标准,可以减少差异化<br><br></span></span><span style="font-size: 14px; color: rgba(128, 0, 0, 1)" lang="EN-US"><span lang="EN-US"><span style="font-size: 16px"><strong>你如何对网站的文件和资源进行优化?</strong></span></span></span></pre>
<pre><span style="font-size: 14px">期待的解决方案包括:</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 文件合并</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 文件最小化<span lang="EN-US">/文件压缩</span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 使用<span lang="EN-US"> CDN 托管</span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 缓存的使用(多个域名来提供缓存)</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 其他</span></pre>
<ul>
<li><span style="font-size: 14px; color: rgba(128, 0, 0, 1)" lang="EN-US"><span lang="EN-US"><span style="font-size: 16px"><strong><strong>请说出三种减少页面加载时间的方法?</strong></strong></span></span></span></li>
</ul>
<pre><span style="font-size: 14px">1、压缩css、js文件</span><br><span style="font-size: 14px">2、合并js、css文件,减少http请求</span><br><span style="font-size: 14px">3、外部js、css文件放在最底下</span><br><span style="font-size: 14px">4、减少dom操作,尽可能用变量替代不必要的dom操作</span></pre>
<p><span style="font-size: 16px"><strong>  <span style="color: rgba(128, 0, 0, 1)">你有哪些性能优化的方法?</span></strong></span></p>
<p style="margin-left: 30px">(详情请看雅虎14条性能优化原则)。</p>
<pre>(1) 减少http请求次数:CSS Sprites, JS、CSS源码压缩、图片大小控制合适;网页Gzip,CDN托管,data缓存 ,图片服务器。</pre>
<pre>(2) 前端模板 JS+数据,减少由于HTML标签导致的带宽浪费,前端用变量保存AJAX请求结果,每次操作本地变量,不用请求,减少请求次数</pre>
<pre>(3) 用innerHTML代替DOM操作,减少DOM操作次数,优化javascript性能。</pre>
<pre>(4) 当需要设置的样式很多时设置className而不是直接操作style。</pre>
<pre>(5) 少用全局变量、缓存DOM节点查找的结果。减少IO读取操作。</pre>
<pre>(6) 避免使用CSS Expression(css表达式)又称Dynamic properties(动态属性)。</pre>
<pre>(7) 图片预加载,将样式表放在顶部,将脚本放在底部 &nbsp;加上时间戳。</pre>
<p><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong> 平时如何管理你的项目?</strong></span></p>
<pre>先期团队必须确定好全局样式(globe.css),编码模式(utf-8) 等;</pre>
<pre> &nbsp;编写习惯必须一致(例如都是采用继承式的写法,单样式都写成一行);</pre>
<pre> &nbsp;标注样式编写人,各模块都及时标注(标注关键样式调用的地方);</pre>
<pre> &nbsp;页面进行标注(例如 页面 模块 开始和结束);</pre>
<pre> CSS跟HTML 分文件夹并行存放,命名都得统一(例如style.css);</pre>
<pre> JS 分文件夹存放 命名以该JS功能为准的英文翻译。</pre>
<ul>
<li>
<h3><span style="color: rgba(128, 0, 0, 1)">你如何优化自己的代码?</span></h3>
</li>
</ul>
<p style="margin-left: 30px">代码重用<br>避免全局变量(命名空间,封闭空间,模块化mvc…)<br>拆分函数避免函数过于臃肿<br>注释</p>
<ul>
<li><span style="font-size: 14px; color: rgba(128, 0, 0, 1)" lang="EN-US"><span lang="EN-US"><span style="font-size: 16px"><strong><strong>什么是<span lang="EN-US"> FOUC(无样式内容闪烁)?你如何来避免<span lang="EN-US"> FOUC?</span></span></strong></strong></span></span></span></li>



















</ul>
<pre><span style="font-size: 14px">  FOUC - Flash Of Unstyled Content 文档样式闪烁</span></pre>
<p style="margin-left: 30px"><span style="font-size: 14px"> &lt;style type="text/css" media="all"&gt;@import "../fouc.css";&lt;/style&gt; </span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">而引用CSS文件的@import就是造成这个问题的罪魁祸首。IE会先加载整个HTML文档的DOM,然后再去导入外部的CSS文件,因此,在页面DOM加载完成到CSS导入完成中间会有一段时间页面上的内容是没有样式的,这段时间的长短跟网速,电脑速度都有关系。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"> 解决方法简单的出奇,只要在&lt;head&gt;之间加入一个&lt;link&gt;或者&lt;script&gt;元素就可以了。</span></p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong><span lang="EN-US">js</span></strong><strong>延迟加载的方式有哪些?</strong></span></li>
</ul>
<pre><span style="font-size: 14px">defer和async、动态创建DOM方式(创建script,插入到DOM中,加载完毕后callBack)、按需异步载入js</span></pre>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong><strong>什么叫优雅降级和渐进增强?</strong></strong></span></li>
</ul>
<pre><span style="font-size: 14px">优雅降级:<span lang="EN-US">Web站点在所有新式浏览器中都能正常工作,如果用户使用的是老式浏览器,则代码会检查以确认它们是否能正常工作。由于<span lang="EN-US">IE独特的盒模型布局问题,针对不同版本的<span lang="EN-US">IE的<span lang="EN-US">hack实践过优雅降级了<span lang="EN-US">,为那些无法支持功能的浏览器增加候选方案,使之在旧式浏览器上以某种形式降级体验却不至于完全失效<span lang="EN-US">.</span></span></span></span></span></span></span></pre>
<pre><span style="font-size: 14px">渐进增强:从被所有浏览器支持的基本功能开始,逐步地添加那些只有新式浏览器才支持的功能</span><span lang="EN-US"><span style="font-size: 14px">,向页面增加无害于基础浏览器的额外样</span></span></pre>
<p><span lang="EN-US"><span style="font-size: 16px"><strong>  <span style="color: rgba(128, 0, 0, 1)">对前端界面工程师这个职位是怎么样理解的?它的前景会怎么样?</span></strong></span></span></p>
<pre><span style="font-size: 14px">前端是最贴近用户的程序员,比后端、数据库、产品经理、运营、安全都近。</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> &nbsp; &nbsp;1、实现界面交互</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> &nbsp; &nbsp;2、提升用户体验</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> &nbsp; &nbsp;3、有了<span lang="EN-US">Node.js,前端可以实现服务端的一些事情</span></span></pre>
<pre><span style="font-size: 14px">前端是最贴近用户的程序员,前端的能力就是能让产品从<span lang="EN-US"> 90分进化到<span lang="EN-US"> 100 分,甚至更好,</span></span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 参与项目,快速高质量完成实现效果图,精确到<span lang="EN-US">1px;</span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 与团队成员,<span lang="EN-US">UI设计,产品经理的沟通;</span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 做好的页面结构,页面重构和用户体验;</span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 处理<span lang="EN-US">hack,兼容、写出优美的代码格式;</span></span></pre>
<pre><span style="font-size: 14px" lang="EN-US"> 针对服务器的优化、拥抱最新前端技术。<br></span></pre>
<h2 style="margin-left: 30px"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>说说最近最流行的一些东西吧?常去哪些网站?</strong></span></h2>
<pre><span style="font-size: 14px">Node.js、Mongodb、npm、MVVM、MEAN、three.js,React 。</span></pre>
<pre><span style="font-size: 14px">网站:w3cfuns,sf,hacknews,CSDN,慕课,博客园,InfoQ,w3cplus等</span></pre>
</div>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>es6相关知识点</strong></span></li>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>Map、Set</strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><strong>https://www.liaoxuefeng.com/wiki/1022910821149312/1023024181109440</strong></span></span></p>
<p style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><strong>https://www.runoob.com/w3cnote/es6-map-set.html</strong></span></span></p>
<p style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><strong><span style="color: rgba(255, 0, 0, 1)">初始化<code>Map</code>需要一个二维数组,或者直接初始化一个空<code>Map</code>。</span><code><br></code></strong></span></span></p>
<ul>
<li>
<h2><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">Maps 和 Objects 的区别?</span></h2>

</li>

</ul>
<p style="margin-left: 30px"><span style="font-size: 14px">一个 Object 的键只能是字符串或者 Symbols,但一个 Map 的键可以是任意值。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">Map 中的键值是有序的(FIFO 原则),而添加到对象中的键则不是。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">Map&nbsp;的键值对个数可以从 size 属性获取,而&nbsp;Object&nbsp;的键值对个数只能手动计算。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">Object 都有自己的原型,原型链上的键名有可能和你自己在对象上的设置的键名产生冲突。</span></p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>for in 、for of区别?</strong></span></li>

</ul>
<p style="margin-left: 30px"><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><strong>例一:</strong></span></p>
<div class="cnblogs_code">
<pre>    const obj =<span style="color: rgba(0, 0, 0, 1)"> {
      a: </span>1<span style="color: rgba(0, 0, 0, 1)">,
      b: </span>2<span style="color: rgba(0, 0, 0, 1)">,
      c: </span>3<span style="color: rgba(0, 0, 0, 1)">
    }
    </span><span style="color: rgba(0, 0, 255, 1)">for</span> (let i <span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> obj) {
      console.log(i) </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> a、 b、c </span>
<span style="color: rgba(0, 0, 0, 1)">    }
    </span><span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> (let i of obj) {
      console.log(i)</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> Uncaught TypeError: obj is not iterable 报错了</span>
    }</pre>
</div>
<p style="margin-left: 30px"><span style="font-size: 14px"><strong>例二:</strong></span></p>
<div class="cnblogs_code">
<pre>    const arr = ['a', 'b', 'c'<span style="color: rgba(0, 0, 0, 1)">]
    </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> for in 循环</span>
    <span style="color: rgba(0, 0, 255, 1)">for</span> (let i <span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> arr) {
      console.log(i)</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">0,1,2 返回的数据下标</span>
<span style="color: rgba(0, 0, 0, 1)">    }
    </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> for of</span>
    <span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> (let i of arr) {
      console.log(i)</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">a,b,c</span>
    }</pre>
</div>
<p style="margin-left: 30px"><span style="font-size: 14px"><strong>例三:</strong></span></p>
<div class="cnblogs_code">
<pre>    const arr = ['a', 'b'<span style="color: rgba(0, 0, 0, 1)">]
    </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 手动给 arr数组添加一个属性</span>
    arr.name = 'qiqingfu'
    <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> for in 循环可以遍历出 name 这个键名</span>
    <span style="color: rgba(0, 0, 255, 1)">for</span> (let i <span style="color: rgba(0, 0, 255, 1)">in</span><span style="color: rgba(0, 0, 0, 1)"> arr) {
      console.log(i) </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> a,b,name </span>
<span style="color: rgba(0, 0, 0, 1)">    }
    </span><span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> (let i of arr) {
      console.log(i)</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">a,b</span>
    }</pre>
</div>
<h2 style="max-width: 100%; font-family: &quot;Helvetica Neue&quot;, &quot;Segoe UI&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Verdana, sans-serif; margin-left: 30px"><span style="font-size: 14px">结合上面的例子,分析得出:</span></h2>
<p style="margin-left: 30px"><span style="font-size: 14px">for...in 语句用于遍历数组或者对象的属性(对数组或者对象的属性进行循环操作)。</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">for in得到对对象的key或数组,字符串的下标</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">for of和forEach一样,是直接得到值</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">for of不能对象,会报错</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px; color: rgba(255, 0, 0, 1)">简单说,for in是遍历键名,for of是遍历键值。</span></p>
<ul>
<li><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>var let const的区别</strong></span></li>
</ul>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; margin-left: 30px"><span style="font-size: 14px">var声明变量可以重复声明,而let不可以重复声明</span></p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  var是不受限于块级的,而let是受限于块级</span></p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  var会与window相映射(会挂一个属性),而let不与window相映射</span></p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  var可以在声明的上面访问变量,而let有暂存死区,在声明的上面访问变量会报错</span></p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  const声明之后必须赋值,否则会报错</span></p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  const定义不可变的量,改变了就会报错</span></p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  const和let一样不会与window相映射、支持块级作用域、在声明的上面访问变量会报错</span></p>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; margin-left: 30px"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">箭头函数的理解?</span></strong></span></p>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; margin-left: 30px"><span style="font-size: 16px"><span style="font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif">https://www.cnblogs.com/mengff/p/9656486.html</span></span></p>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; margin-left: 30px"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px"><span style="font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif">普通函数和箭头函数区别?</span></span></strong></span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">箭头函数</span>
let fun = () =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
    console.log(</span>'lalalala'<span style="color: rgba(0, 0, 0, 1)">);
}
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">普通函数</span>
<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)"> fun() {
    console.log(</span>'lalla'<span style="color: rgba(0, 0, 0, 1)">);
}</span></pre>
</div>
<h2 style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14px">  <span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">使用箭头函数应注意什么?</span></strong></span></span></h2>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; margin-left: 30px">(1)用了箭头函数,this就不是指向window,而是父级(指向是可变的)</p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif">  (2)不能够使用arguments对象</p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif">  (3)不能用作构造函数,这就是说不能够使用new命令,否则会抛出一个错误</p>
<p style="padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif">  (4)不可以使用yield命令,因此箭头函数不能用作 Generator 函数</p>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144515019-1097077190.png"></p>
<p style="padding-top: 0; padding-right: 0; padding-bottom: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144538126-1773355999.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144546631-2040680388.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144555602-1972728244.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;  <img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144628578-967252747.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144648214-1678248652.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210510144657375-249297271.png"></p>
<ul>
<li><span style="font-size: 16px"><strong>代码算法之类</strong></span></li>
</ul>
<p style="margin-left: 30px"><span style="font-size: 16px"><strong>数组去重i</strong></span><span style="font-size: 16px"><strong>ndexOf</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">        var arr=
        var arr2=[]
        for(var i=0;i&lt;arr.length;i++){
                if(arr2.indexOf(arr)&lt;0){
                        arr2.push(arr)
                }
        }
        console.log(arr2)&nbsp;</pre>
</div>
<p>  <span style="font-size: 16px"><strong>es6方法</strong></span><span style="font-size: 16px"><strong>数组去重</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">      let a =
        let b=new Set([...a])
        console.log(b);
        b=[...b];
        console.log(b)      </pre>
</div>
<p>  <span style="font-size: 16px"><strong>冒泡排序</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">                var arr=;
                var temp=0;
                for (var i=0;i&lt;arr.length;i++) {
                        for(var j=0;j&lt;arr.length-i;j++){
                                if(arr&lt;arr){
                                        temp=arr;
                                        arr=arr;
                                        arr=temp;
                                }
                        }
                }
                console.log(arr)
</pre>
</div>
<p>  <span style="font-size: 16px"><strong>获取url中的参数</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">//测试地址:http://www.runobb.com/jqur/dfev.html?name=xiaohong&amp;age=22
      function showWindowHref(){
                var sHref=window.location.href;
                var args=sHref.split('?');
                if(args==sHref){
                        return '';
                }
                var aa=args.split('&amp;');
                var obj={}
                for (var i=0;i&lt;aa.length;i++) {
                        var bb=aa.split('=')
                        obj]=bb
                }
                return obj;
                               
        }
</pre>
</div>
<p>  <span style="font-size: 16px"><strong>降维数组</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">   //利用[].concat.apply实现降维   
      var arr=[,];
      function Jw(obj){
                console.log(Array.prototype.concat.apply([],obj))
                return Array.prototype.concat.apply([],obj);
      }
      Jw(arr);
    //递归
      function reduceDimension(arr){
            let ret = [];
            let toArr = function(arr){
                arr.forEach(function(item){
                  item instanceof Array ? toArr(item) : ret.push(item);
                });
            }
            toArr(arr);
            console.log(ret)
            return ret;
      }
      reduceDimension(]])                  
</pre>
</div>
<p>  <strong><span style="font-size: 16px">js<span style="color: rgba(34, 34, 38, 1); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-variant-ligatures: common-ligatures">判断一个字符串中出现次数最多的字符,统计这个次数</span></span></strong></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">var str = 'asdfssaaasasasasaa';
var json = {};
for (var i = 0; i &lt; str.length; i++) {
    if(!json){
       json = 1;
    }else{
       json++;
    }
};
var iMax = 0;
var iIndex = '';
for(var i in json){
    if(json&gt;iMax){
         iMax = json;
         iIndex = i;
    }
}
console.log('出现次数最多的是:'+iIndex+'出现'+iMax+'次');//出现次数最多的是:a出现 9次
</pre>
</div>
<p> <span style="font-size: 16px"><strong>写一个function,清除字符串前后的空格。(兼容所有浏览器)</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">function trim(str) {
    if (str &amp; typeof str === "string") {
      return str.replace(/(^s*)|(s*)$/g,""); //去除前后空白符
    }
}
</pre>
</div>
<p> <strong><span style="font-size: 16px">如何用jquery禁用浏览器的前后进退按钮?</span></strong></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">&lt;script type="text/javascript" language="javascript"&gt;

$(document).ready(function() {

   window.history.forward(1);

   //OR

   window.history.forward(-1);

});

&lt;/script&gt;</pre>
</div>
<p> <span style="font-size: 16px"><strong>获取页面中所有的checkbox怎么做?(不使用第三方框架)</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">var inputs = document.getElementsByTagName("input");//获取所有的input标签对象
var checkboxArray = [];//初始化空数组,用来存放checkbox对象。
for(var i=0;i&lt;inputs.length;i++){
var obj = inputs;
if(obj.type=='checkbox'){
   checkboxArray.push(obj);
}
}
</pre>
</div>
<p> <span style="font-size: 16px"><strong>程序中捕获异常的方法?</strong></span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;">try{

}catch(e){

}finally{

}
</pre>
</div>
<p>  </p>
<h4><span style="font-size: 18pt"><strong>Vue框架</strong></span></h4>
<p><span style="font-size: 14px">https://zhuanlan.zhihu.com/p/92407628</span></p>
<h2 data-id="heading-1"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">那首先谈谈你对Vue的理解吧?vue.js是什么?</span></h2>
<p><span style="color: rgba(0, 0, 0, 1); font-size: 14px"><span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">Vue (读音 /vjuː/,类似于&nbsp;</span><span style="font-weight: 600; font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">view</span><span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">) 是一套用于构建用户界面的</span><span style="font-weight: 600; font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">渐进式框架</span><span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">。与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用。Vue 的核心库只关注视图层,不仅易于上手,还便于与第三方库或既有项目整合。另一方面,当与</span></span><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 14px">现代化的工具链</span></span></span><span style="color: rgba(0, 0, 0, 1); font-size: 14px"><span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">以及各种</span>支持类库<span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">结合使用时,Vue 也完全能够为复杂的单页应用提供驱动。</span></span></p>
<p><span style="color: rgba(0, 0, 0, 1); font-size: 14px"><span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif; word-spacing: 0.8px">vue是一个渐进式框架,</span><span style="font-family: &quot;Source Sans Pro&quot;, &quot;Helvetica Neue&quot;, Arial, sans-serif"><span style="word-spacing: 0.8px">相当于view层, 双向数据绑定,&nbsp; 他更轻量, 性能上更高效, 比其他框架更容易上手, 学习成本低, vue需要一个el对象进行实例化,&nbsp;</span></span></span></p>
<h2 style="box-sizing: border-box; outline: 0; margin: 8px 0 16px; padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; color: rgba(79, 79, 79, 1); line-height: 32px; overflow-wrap: break-word; font-variant-ligatures: common-ligatures"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">Vue与Angular以及React的区别?</span></h2>
<p>angular是mvvm框架, 而vue是一个渐进式的框架, 相当于view层, 都有双向数据绑定,&nbsp; 但是angular中的双向数据绑定是基于脏检查机制, vue的双向数据绑定是基于ES5的getter和setter来实现, 而angular是有自己实现一套模板编译规则,vue比angular更轻量, 性能上更高效, 比angular更容易上手, 学习成本低, vue需要一个el对象进行实例化, 而angular是整个html页面下的,单页面应用, 而vue可以有个vue实例</p>
<p><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 14px"><span>1</span></span><span style="font-size: 14px"><span>.与AngularJS的区别</span></span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>相同点:</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>都支持指令:内置指令和自定义指令;都支持过滤器:内置过滤器和自定义过滤器;都支持双向数据绑定;都不支持低端浏览器。</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>不同点:</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>AngularJS的学习成本高,比如增加了Dependency Injection特性,而Vue.js本身提供的API都比较简单、直观;在性能上,AngularJS依赖对数据做脏检查,所以Watcher越多越慢;Vue.js使用基于依赖追踪的观察并且使用异步队列更新,所有的数据都是独立触发的。</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>2.与React的区别</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>相同点:</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>React采用特殊的JSX语法,Vue.js在组件开发中也推崇编写.vue特殊文件格式,对文件内容都有一些约定,两者都需要编译后使用;中心思想相同:一切都是组件,组件实例之间可以嵌套;都提供合理的钩子函数,可以让开发者定制化地去处理需求;都不内置列数AJAX,Route等功能到核心包,而是以插件的方式加载;在组件开发中都支持mixins的特性。</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>不同点:</span></span></p>
<p><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span>React采用的Virtual DOM会对渲染出来的结果做脏检查;Vue.js在模板中提供了指令,过滤器等,可以非常方便,快捷地操作Virtual DOM。</span></span></p>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">vue 的生命周期?</span></strong></span></p>
<p><span style="font-size: 14px">实例从创建到销毁的过程,就是生命周期。也就是从开始创建、初始化数据、编译模板、挂载Dom→渲染、更新→渲染、卸载等一系列过程,我们称这是&nbsp;Vue&nbsp;的生命周期。</span></p>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong><span style="font-size: 14px">应用场景</span></strong></span></p>
<p><span style="font-size: 14px">beforeCreate:在new一个vue实例后,只有一些默认的生命周期钩子和默认事件,其他的东西都还没创建。在beforeCreate生命周期执行的时候,data和methods中的数据都还没有初始化。不能在这个阶段使用data中的数据和methods中的方法<br>create:data 和 methods都已经被初始化好了,如果要调用 methods 中的方法,或者操作 data 中的数据,最早可以在这个阶段中操作<br>beforeMount:执行到这个钩子的时候,在内存中已经编译好了模板了,但是还没有挂载到页面中,此时,页面还是旧的<br>mounted:执行到这个钩子的时候,就表示Vue实例已经初始化完成了。此时组件脱离了创建阶段,进入到了运行阶段。 如果我们想要通过插件操作页面上的DOM节点,最早可以在和这个阶段中进行<br>beforeUpdate: 当执行这个钩子时,页面中的显示的数据还是旧的,data中的数据是更新后的, 页面还没有和最新的数据保持同步<br>updated:页面显示的数据和data中的数据已经保持同步了,都是最新的<br>beforeDestory:Vue实例从运行阶段进入到了销毁阶段,这个时候上所有的 data 和 methods , 指令, 过滤器 ……都是处于可用状态。还没有真正被销毁<br>destroyed: 这个时候上所有的 data 和 methods , 指令, 过滤器 ……都是处于不可用状态。组件已经被销毁了。</span></p>
<p><span style="font-size: 14px; color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">vue生命周期的作用是什么?</span></strong></span></p>
<p><span style="font-size: 14px">
它的生命周期中有多个事件钩子,让我们在控制整个Vue实例的过程时更容易形成好的逻辑。</span></p>
<p><span style="font-size: 14px; color: rgba(128, 0, 0, 1)">
<span style="font-size: 16px"><strong>vue生命周期总共有几个阶段?</strong></span></span></p>
<p><span style="font-size: 14px">
它可以总共分为8个阶段:创建前/后,&nbsp;载入前/后,更新前/后,销毁前/销毁后<br></span></p>
<p><span style="font-size: 14px"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>第一次页面加载会触发哪几个钩子?</strong></span><br>答:beforeCreate, created, beforeMount, mounted</span></p>
<p><span style="font-size: 14px"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">vue获取数据在哪个周期函数?</span></strong></span><br>答:一般 created/beforeMount/mounted 皆可.<br>比如如果你要操作 DOM , 那肯定 mounted 时候才能操作.</span></p>
<p><strong><span style="font-size: 16px"><span style="color: rgba(128, 0, 0, 1)">mvvm 框架是什么?</span><br></span></strong><span style="font-size: 16px"><span style="font-size: 14px">答:vue是实现了双向数据绑定的mvvm框架,当视图改变更新模型层,当模型层改变更新视图层。在vue中,使用了双向绑定技术,就是View的变化能实时让Model发生变化,而Model的变化也能实时更新到View。</span></span></p>
<p><strong><span style="font-size: 16px"><span style="color: rgba(128, 0, 0, 1)">Vue中双向数据绑定是如何实现的?</span><br></span></strong><span style="font-size: 14px">答:vue 双向数据绑定是通过 数据劫持 结合 发布订阅模式的方式来实现的, 也就是说数据和视图同步,数据发生变化,视图跟着变化,视图变化,数据也随之发生改变;<br>核心:关于VUE双向数据绑定,其核心是 Object.defineProperty()方法。</span></p>
<h2 data-id="heading-3"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">vue是如何实现响应式数据的呢?(响应式数据原理)❗</span></h2>
<p><span style="font-size: 16px">https://blog.csdn.net/kzj0916/article/details/108298865</span></p>
<p><strong><span style="font-size: 14px; background-color: rgba(255, 255, 0, 1)">原理:</span></strong></p>
<p><span style="font-size: 14px">相信用过vue的都知道,vue中data中定义的数据会随着我们通过方法改变该数据的同时,页面上相关此数据的也会相应的刷新,实现响应式数据。可你知道它是如何实现这一功能的吗?下面让我们来了解了解它是如何做到这神奇操作的。<br></span></p>
<p><span style="background-color: rgba(255, 255, 0, 1)"><strong><span style="font-size: 14px">Object.defineProperty 监听修改读取数据:</span></strong></span></p>
<p><span style="font-size: 14px">Object.defineProperty(obj, prop, descriptor) 可传入三个值,其作用是该方法会直接在一个对象上定义一个新属性,或者修改一个对象的现有属性,并返回此对象。</span><br><span style="font-size: 14px">第一个值传入要修改的对象</span><br><span style="font-size: 14px">第二个值传入该对象中要修改的key</span><br><span style="font-size: 14px">第三个值是一个对象,里面有set 和get两种方法 set为值发生修改是所做的操作 get为读取改值时的操作</span><br><span style="font-size: 14px">默认配置如下</span></p>
<p><span style="font-size: 14px"><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210511130503189-1952509412.png"></span></p>
<p>现在我们来研究下vue是如何利用Object.defineProperty 监听修改读取数据的</p>
<p>我们创建一个对象,并利用Object.keys()将对象中的key返回到一个数组中,并对该数组forEach遍历<br>将key对应值先取过来,对这个对象中每个不同的key通过Object.defineProperty修改并监听数据的变化,在修改该key对应的value值时,调用set方法 打印下监听xxxx数据改变 并将修改值赋给value<br>在读取该key对应的value值时,调用get方法 打印下获取xxxx对应的值 并直接返回当前value值</p>
<p><img src="https://img2020.cnblogs.com/blog/1129706/202105/1129706-20210511130717460-1793992941.png"></p>
<h2 data-id="heading-4"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">vue中是如何检测数组变化的呢?</span></h2>
<p><span style="font-size: 14px">vue.set()</span></p>
<p><span style="font-size: 14px"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>分别简述computed和watch的使用场景?</strong></span><br>答:computed:<br>    当一个属性受多个属性影响的时候就需要用到computed<br>    最典型的栗子: 购物车商品结算的时候<br>  watch:<br>    当一条数据影响多条数据的时候就需要用watch<br>    栗子:搜索数据</span></p>
<p><span style="font-size: 14px"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>created和mounted的区别?</strong></span><br>答:created:在模板渲染成html前调用,即通常初始化某些属性值,然后再渲染成视图。<br>mounted:在模板渲染成html后调用,通常是初始化页面完成后,再对html的dom节点进行一些需要的操作。</span></p>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">params和query的区别?</span></strong></span></p>
<p><span style="font-size: 14px">用法:query要用path来引入,params要用name来引入,接收参数都是类似的,分别是this.$route.query.name和this.$route.params.name。<br>url地址显示:query更加类似于我们ajax中get传参,params则类似于post,说的再简单一点,前者在浏览器地址栏中显示参数,后者则不显示<br>注意点:query刷新不会丢失query里面的数据<br>params刷新 会 丢失 params里面的数据。</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">query语法:</span>
<span style="color: rgba(0, 0, 255, 1)">this</span>.$router.push({path:"地址",query:{id:"123"<span style="color: rgba(0, 0, 0, 1)">}}); <span style="color: rgba(51, 153, 102, 1)">//这是传递参数
</span></span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.$route.query.id; <span style="color: rgba(51, 153, 102, 1)">//这是接受参数
</span></span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">params语法:</span>
<span style="color: rgba(0, 0, 255, 1)">this</span>.$router.push({name:"地址",params:{id:"123"<span style="color: rgba(0, 0, 0, 1)">}}); <span style="color: rgba(51, 153, 102, 1)">//这是传递参数
</span></span><span style="color: rgba(0, 0, 255, 1)">this</span>.$route.params.id; <span style="color: rgba(51, 153, 102, 1)">//这是接受参数</span></pre>
</div>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">$nextTick的使用?</span></strong></span><br><span style="font-size: 14px">答:当你修改了data的值然后马上获取这个dom元素的值,是不能获取到更新后的值,</span><br><span style="font-size: 14px">你需要使用$nextTick这个回调,让修改后的data值渲染更新到dom元素之后在获取,才能成功。</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 修改数据</span>
vm.msg = 'Hello'
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> DOM 还未更新</span>
Vue.nextTick(<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)"> () {
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> DOM 更新</span>
})</pre>
</div>
<p><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>&lt;keep-alive&gt;&lt;/keep-alive&gt;的作用是什么?</strong></span><br><span style="font-size: 14px">答:keep-alive 是 Vue 内置的一个组件,可以使被包含的组件保留状态,或避免重新渲染。</span></p>
<p><span style="font-size: 14px"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)"><strong>为什么使用key?</strong></span><br>答:需要使用key来给每个节点做一个唯一标识,Diff算法就可以正确的识别此节点。<br>作用主要是为了高效的更新虚拟DOM。</span></p>
<p data-id="heading-21"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">vue组件中的data为什么是函数?</span></strong></span></p>
<p><span style="color: rgba(18, 18, 18, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: 14px">答:因为JavaScript的特性所导致,在component中,data必须以函数的形式存在,不可以是对象。</span><br style="color: rgba(18, 18, 18, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: medium"><span style="color: rgba(18, 18, 18, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: 14px">  组建中的data写成一个函数,数据以函数返回值的形式定义,这样每次复用组件的时候,都会返回一份新的data,相当于每个组件实例都有自己私有的数据空间,它们只负责各自维护的数据,不会造成混乱。而单纯的写成对象形式,就是所有的组件实例共用了一个data,这样改一个全都改了。</span></p>
<p><span style="color: rgba(18, 18, 18, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: 14px"><span style="font-weight: 600; font-size: 16px; color: rgba(128, 0, 0, 1)">vue常用的修饰符?</span><br style="font-size: medium"></span><span style="font-size: 14px"><span style="color: rgba(18, 18, 18, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif">答:.stop:等同于JavaScript中的event.stopPropagation(),防止事件冒泡;</span><span style="color: rgba(18, 18, 18, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, &quot;Source Han Sans SC&quot;, &quot;Noto Sans CJK SC&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif"><br style="font-size: medium">.prevent:等同于JavaScript中的event.preventDefault(),防止执行预设的行为(如果事件可取消,则取消该事件,而不停止事件的进一步传播);<br style="font-size: medium">.capture:与事件冒泡的方向相反,事件捕获由外到内;<br style="font-size: medium">.self:只会触发自己范围内的事件,不包含子元素;<br style="font-size: medium">.once:只会触发一次。</span></span></p>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-size: 16px">vuex</span></strong></span></p>
<p><span style="font-size: 14px">https://blog.csdn.net/u012967771/article/details/114132555</span></p>
<h3 style="box-sizing: border-box; outline: 0; margin: 8px 0 16px; padding: 0; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, SimHei, Arial, SimSun; font-size: 22px; color: rgba(79, 79, 79, 1); line-height: 30px; overflow-wrap: break-word"><span style="font-size: 16px; color: rgba(128, 0, 0, 1)">关于VueX</span></h3>
<p><span style="font-size: 14px">VueX是适用于在Vue项目开发时使用的状态管理工具。试想一下,如果在一个项目开发中频繁的使用组件传参的方式来同步data中的值,一旦项目变得很庞大,管理和维护这些值将是相当棘手的工作。为此,Vue为这些被多个组件频繁使用的值提供了一个统一管理的工具——VueX。在具有VueX的Vue项目中,我们只需要把这些值定义在VueX中,即可在整个Vue项目的组件中使用。</span></p>
<p><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px">使用Vuex的目的</span></strong></span></p>
<p style="box-sizing: border-box; outline: 0; margin: 8px 0 0 32px; padding-top: 0; padding-right: 0; padding-bottom: 0; list-style: disc; overflow-wrap: break-word"><span style="font-size: 14px">实现多组件状态管理。多个组件之间需要数据共享时,Vuex是个很好的帮手哦</span></p>
<p style="box-sizing: border-box; outline: 0; margin: 8px 0 0 2px; padding-top: 0; padding-right: 0; padding-bottom: 0; list-style: disc; overflow-wrap: break-word"><span style="color: rgba(128, 0, 0, 1)"><strong><span style="font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 16px">Vuex 的五大核心</span></strong></span></p>
<p style="box-sizing: border-box; outline: 0; margin: 8px 0 0 32px; padding-top: 0; padding-right: 0; padding-bottom: 0; list-style: disc; overflow-wrap: break-word"><span style="font-size: 14px">其中state和mutation是必须的,其他可根据需求来加</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px; color: rgba(0, 0, 0, 1)"><span style="font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun">1、state:</span><span style="background-color: rgba(238, 240, 244, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun">负责状态管理,类似于vue中的data,用于初始化数据&nbsp; &nbsp; </span></span><span style="background-color: rgba(250, 250, 250, 1); color: rgba(51, 153, 102, 1); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-style: italic; white-space: pre">//状态管理</span></p>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="color: rgba(0, 0, 0, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun">2、mutation:</span><span style="background-color: rgba(238, 240, 244, 1); color: rgba(79, 79, 79, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun"><span style="color: rgba(0, 0, 0, 1)">专用于修改state中的数据,通过commit触发&nbsp; &nbsp;</span> &nbsp; </span></span><span style="background-color: rgba(250, 250, 250, 1); color: rgba(51, 153, 102, 1); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-style: italic; white-space: pre">//修改state</span>&nbsp;</p>
<p style="margin-left: 30px"><span style="font-size: 14px"><span style="color: rgba(0, 0, 0, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun">3、action:</span><span style="background-color: rgba(238, 240, 244, 1); color: rgba(79, 79, 79, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun"><span style="color: rgba(0, 0, 0, 1)">可以处理异步,通过dispatch触发,不能直接修改state,首先在组件中通过dispatch触发action,然后在action函数内部commit触发mutation,通过mutation修改state状态值&nbsp;</span> &nbsp;&nbsp;</span></span><span style="background-color: rgba(250, 250, 250, 1); color: rgba(51, 153, 102, 1); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-style: italic; white-space: pre">//异步操作</span></p>
<p style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 14px">4、getter:</span><span style="background-color: rgba(238, 240, 244, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 14px">Vuex中的计算属性,相当于vue中的computed,依赖于state状态值,状态值一旦改变,getter会重新计算,也就是说,当一个数据依赖于另一个数据发生变化时,就要使用getter</span></span></p>
<p style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 14px">5、module:</span><span style="background-color: rgba(238, 240, 244, 1); color: rgba(79, 79, 79, 1); font-family: -apple-system, &quot;SF UI Text&quot;, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif, SimHei, SimSun; font-size: 14px"><span style="color: rgba(0, 0, 0, 1)">模块化管理&nbsp;</span> &nbsp;&nbsp;</span><span style="background-color: rgba(250, 250, 250, 1); color: rgba(51, 153, 102, 1); font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-style: italic; white-space: pre">//模块</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 导入vue及vuex</span>
import Vue from 'vue'<span style="color: rgba(0, 0, 0, 1)">
import Vuex from </span>'vuex'
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 挂载vuex</span>
<span style="color: rgba(0, 0, 0, 1)">Vue.use(Vuex)

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 创建vuex对象并向外暴露</span>
export <span style="color: rgba(0, 0, 255, 1)">default</span> <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Vuex.Store({
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 全局属性变量</span>
<span style="color: rgba(0, 0, 0, 1)">state: {
},
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 全局同步方法, 调用方法,this.$store.commit("xxx")</span>
<span style="color: rgba(0, 0, 0, 1)">mutations: {
},
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 异步方法 调用方法,this.$store.dispatch("xxx") </span>
<span style="color: rgba(0, 0, 0, 1)">actions: {
},
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> Vuex属性计算,在视图里面当变量使用</span>
<span style="color: rgba(0, 0, 0, 1)">getters: {
},
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 模块化注册</span>
<span style="color: rgba(0, 0, 0, 1)">modules: {
}
})</span></pre>
</div>
<p><span style="font-size: 16px"><strong>action与mutation的区别?</strong></span></p>
<div class="cnblogs_code">
<pre>const store = <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Vuex.Store({
state: {
    count: </span>0<span style="color: rgba(0, 0, 0, 1)">
},
mutations: {
    increment (state) {
      state.count</span>++<span style="color: rgba(0, 0, 0, 1)">
    }
},
actions: {
    increment (context) {
      context.commit(</span>'increment'<span style="color: rgba(0, 0, 0, 1)">)
    }
}
})</span></pre>
</div>
<p>1、流程顺序</p>
<p>“相应视图—&gt;修改State”拆分成两部分,视图触发Action,Action再触发Mutation。</p>
<p>2、角色定位</p>
<p>基于流程顺序,二者扮演不同的角色。</p>
<p>Mutation:专注于修改State,理论上是修改State的唯一途径。</p>
<p>Action:业务代码、异步请求。</p>
<p>3、限制</p>
<p>角色不同,二者有不同的限制。</p>
<p>Mutation:必须同步执行。</p>
<p>Action:可以异步,但不能直接操作State。</p>
<p><span style="font-size: 18pt"><strong>微信小程序</strong></span></p>
<p style="margin-left: 30px"><span style="font-size: 14px">登录流程是调wx.login获取code传给后台服务器获取微信用户唯一标识openid及本次登录的会话密钥(session_key)等)。拿到开发者服务器传回来的会话密钥(session_key)之后,前端要保存wx.setStorageSync('sessionKey', 'value')</span></p>
<p style="margin-left: 30px" align="left"><span style="font-size: 14px">持久登录状态:session信息存放在cookie中以请求头的方式带回给服务端,放到request.js里的wx.request的header里</span></p>
<p style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 11pt" lang="EN-US">navigator </span><span style="font-size: 11pt; font-family: Consolas">跳转页面标签</span></span></p>
<p style="margin-bottom: 8.4pt; margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 11pt; font-family: Calibri, sans-serif; font-weight: normal" lang="EN-US">wx.redirectTo</span><span style="font-size: 11pt; font-family: Consolas; font-weight: normal">关闭当前页面,跳转到新的页面(类似重定向)</span></span></p>
<p style="margin-bottom: 8.4pt; margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 11pt; font-family: Calibri, sans-serif; font-weight: normal" lang="EN-US">wx.switchTab</span><span style="font-size: 11pt; font-family: Consolas; font-weight: normal">跳转到</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; font-weight: normal" lang="EN-US"> tabBar </span><span style="font-size: 11pt; font-family: Consolas; font-weight: normal">页面,并关闭其他所有非</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; font-weight: normal" lang="EN-US"> tabBar </span><span style="font-size: 11pt; font-family: Consolas; font-weight: normal">页面</span></span></p>
<p class="MsoNormal" style="line-height: 13.5pt; background: rgba(255, 255, 254, 1); margin-left: 30px" align="left"><span style="font-size: 11pt; color: rgba(0, 0, 0, 1)" lang="EN-US">&lt;navigator url="./../classificationdetails/classification"&gt;</span></p>
<p class="MsoNormal" style="line-height: 13.5pt; background: rgba(255, 255, 254, 1); margin-left: 30px" align="left"><span style="font-size: 11pt; color: rgba(0, 0, 0, 1)" lang="EN-US">wx.navigateTo({url: './../shouquan/index'})</span></p>
<p class="MsoNormal" style="line-height: 13.5pt; background: rgba(255, 255, 254, 1); margin-left: 30px" align="left"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 11pt" lang="EN-US">wx:for</span><span style="font-size: 11pt; font-family: Consolas">、</span><span style="font-size: 11pt"> <span lang="EN-US">wx:if</span></span></span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 11pt" lang="EN-US">bindtap</span><span style="font-size: 11pt; font-family: Consolas">点击触发函数</span></span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="font-size: 11pt" lang="EN-US">bindtap</span><span style="font-size: 11pt; font-family: Consolas">和</span><span style="font-size: 11pt" lang="EN-US">catchtap </span><span style="font-size: 11pt; font-family: Consolas">(</span><span style="font-size: 11pt" lang="EN-US">bindtap</span><span style="font-size: 11pt; font-family: Consolas">不会阻止事件冒泡</span><span style="font-size: 11pt" lang="EN-US">catchtap</span><span style="font-size: 11pt; font-family: Consolas">可以阻止事件冒泡)</span></span></p>
<p class="MsoNormal" style="margin-left: 30px"><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1); font-family: Consolas"><span style="font-size: 14.6667px">https://segmentfault.com/a/1190000018689948</span></span></span></p>
<h4><strong><span style="font-size: 18pt">计算机网络基础</span></strong></h4>
<p class="MsoNormal"><span style="font-size: 12pt; font-family: 宋体; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin">&nbsp;</span></p><br><br>
来源:https://www.cnblogs.com/vaelcy/p/14736357.html
頁: [1]
查看完整版本: 前端开发面试总结