-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsexer13-ans.html
1 lines (1 loc) · 35.4 KB
/
jsexer13-ans.html
1
<!-- build time:Sat Jun 29 2019 22:18:02 GMT+0800 (GMT+08:00) --><!DOCTYPE html><html class="theme-next pisces use-motion" lang="zh-Hans"><head><meta name="generator" content="Hexo 3.8.0"><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta name="theme-color" content="#222"><script src="/lib/pace/pace.min.js?v=1.0.2"></script><link href="/lib/pace/pace-theme-mac-osx.min.css?v=1.0.2" rel="stylesheet"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="google-site-verification" content="9WuQ1WJ1aHso1UidwWUbTJDopjLU1khin8oZmteflHA"><meta name="baidu-site-verification" content="d7gUtvPjpf"><meta name="360-site-verification" content="be44f90663e3289db63a4079896aab82"><link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"><link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css"><link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css"><link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4"><link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4"><link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4"><link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222"><meta name="keywords" content="数据类型,javascript,web前端,前端面试题,柯里化,Promise,"><meta name="description" content="本篇文章是js基础练习题第十三天的答案及解析部分,纯题目部分请移步js基础练习题 第13天"><meta name="keywords" content="数据类型,javascript,web前端,前端面试题,柯里化,Promise"><meta property="og:type" content="article"><meta property="og:title" content="js练习题第13天 答案及解析"><meta property="og:url" content="https://www.jealyn.top/jsexer13-ans.html"><meta property="og:site_name" content="Jealyn的个人网站"><meta property="og:description" content="本篇文章是js基础练习题第十三天的答案及解析部分,纯题目部分请移步js基础练习题 第13天"><meta property="og:locale" content="zh-Hans"><meta property="og:updated_time" content="2019-03-28T14:24:26.000Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="js练习题第13天 答案及解析"><meta name="twitter:description" content="本篇文章是js基础练习题第十三天的答案及解析部分,纯题目部分请移步js基础练习题 第13天"><script type="text/javascript" id="hexo.configurations">var NexT=window.NexT||{},CONFIG={root:"/",scheme:"Pisces",version:"5.1.4",sidebar:{position:"left",display:"post",offset:12,b2t:!1,scrollpercent:!1,onmobile:!1},fancybox:!0,tabs:!0,motion:{enable:!0,async:!1,transition:{post_block:"fadeIn",post_header:"slideDownIn",post_body:"slideDownIn",coll_header:"slideLeftIn",sidebar:"slideUpIn"}},duoshuo:{userId:"0",author:"博主"},algolia:{applicationID:"",apiKey:"",indexName:"",hits:{per_page:10},labels:{input_placeholder:"Search for Posts",hits_empty:"We didn't find any results for the search: ${query}",hits_stats:"${hits} results found in ${time} ms"}}}</script><link rel="canonical" href="https://www.jealyn.top/jsexer13-ans.html"><title>js练习题第13天 答案及解析 | Jealyn的个人网站</title></head><body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans"><div class="container sidebar-position-left page-post-detail"><div class="headband"></div><a href="https://github.com/jealyn" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513;color:#fff;position:absolute;top:0;border:0;right:0;z-index:999" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin:130px 106px" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style><header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="header-inner"><div class="site-brand-wrapper"><div class="site-meta"><div class="custom-logo-site-title"><a href="/" class="brand" rel="start"><span class="logo-line-before"><i></i></span> <span class="site-title">Jealyn的个人网站</span> <span class="logo-line-after"><i></i></span></a></div><h1 class="site-subtitle" itemprop="description">我的前端后花园</h1></div><div class="site-nav-toggle"><button><span class="btn-bar"></span> <span class="btn-bar"></span> <span class="btn-bar"></span></button></div></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i><br>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i><br>关于</a></li><li class="menu-item menu-item-题目征集"><a href="/collect-exercise/" rel="section"><i class="menu-item-icon fa fa-fw fa-heartbeat"></i><br>题目征集</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i><br>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i><br>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i><br>归档</a></li><li class="menu-item menu-item-search"><a href="javascript:;" class="popup-trigger"><i class="menu-item-icon fa fa-search fa-fw"></i><br>搜索</a></li></ul><div class="site-search"><div class="popup search-popup local-search-popup"><div class="local-search-header clearfix"><span class="search-icon"><i class="fa fa-search"></i> </span><span class="popup-btn-close"><i class="fa fa-times-circle"></i></span><div class="local-search-input-wrapper"><input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input"></div></div><div id="local-search-result"></div></div></div></nav></div></header><main id="main" class="main"><div class="main-inner"><div class="content-wrap"><div id="content" class="content"><div id="posts" class="posts-expand"><article class="post post-type-normal" itemscope itemtype="http://schema.org/Article"><div class="post-block"><link itemprop="mainEntityOfPage" href="https://www.jealyn.top/jsexer13-ans.html"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="jealyn.wang"><meta itemprop="description" content="前端小白一枚"><meta itemprop="image" content="/images/avatar.png"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="Jealyn的个人网站"></span><header class="post-header"><h2 class="post-title" itemprop="name headline">js练习题第13天 答案及解析</h2><div class="post-meta"><span class="post-time"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i> </span><span class="post-meta-item-text"></span> <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-03-28T20:52:28+08:00">2019-03-28 </time></span><span class="post-category"><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-folder-o"></i> </span><span class="post-meta-item-text"></span> <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/JS基础练习题/" itemprop="url" rel="index"><span itemprop="name">JS基础练习题</span> </a></span>, <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/JS基础练习题/答案及解析/" itemprop="url" rel="index"><span itemprop="name">答案及解析</span> </a></span></span><span class="post-meta-divider">|</span> <span class="page-pv"><i class="fa fa-eye"></i> 阅读数 <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>次</span><div class="post-wordcount"><span class="post-meta-item-icon"><i class="fa fa-file-word-o"></i> </span><span class="post-meta-item-text">字数统计:</span> <span title="字数统计">865 字 </span><span class="post-meta-divider">|</span> <span class="post-meta-item-icon"><i class="fa fa-clock-o"></i> </span><span class="post-meta-item-text">阅读时长 ≈</span> <span title="阅读时长">3 分钟</span></div></div></header><div class="post-body" itemprop="articleBody"><blockquote><p>本篇文章是js基础练习题第十三天的答案及解析部分,纯题目部分请移步<a href="/jsexer13.html" title="js基础练习题 第13天">js基础练习题 第13天</a></p></blockquote><a id="more"></a><h2 id="正文"><a href="#正文" class="headerlink" title="正文"></a>正文</h2><p>1.js有几种基本数据类型?<br></p><div class="note info"><h3>答案:在js中一共有7种基本数据类型,分别是<code>number</code>, <code>string</code>, <code>boolean</code>, <code>null</code>, <code>undefined</code>, <code>symbol</code>, <code>bigint</code></h3></div><div class="note warning"><p>关于<code>symbol</code>的介绍,可以参照<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol" target="_blank" rel="noopener">MDN symbol</a>,关于<code>bigint</code>的介绍,可以参看<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/BigInt" target="_blank" rel="noopener">MDN bigint</a></p></div><br>2.js有几种引用数据类型?<div class="note info"><h3>答案:在js中一共有3种引用数据类型,分别是<code>object</code>、<code>array</code>、<code>function</code></h3></div><br>3.简述基本数据类型与引用数据类型的区别。<br><div class="note info"><h3>从数据存储上来说,基本数据类型的名(key)和值(value)都存储在栈内存中;而引用数据类型的名存在栈内存中,值存在于堆内存中,栈内存会提供一个引用的地址(指针)指向堆内存中的值。</h3></div><br>4.深拷贝与浅拷贝有何区别?如何利用js实现一个简单的深拷贝,试给出你的代码。<div class="note info"><p></p><h3>浅拷贝是对栈内存中的值(即指针)的拷贝,拷贝前后对象指向的是堆内存中的同一个值;深拷贝是指在堆内存中开辟一个新的内存专门来存放拷贝值,此时拷贝后的值与原值就是相互独立、互不影响的。</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 可以使用递归去复制所有层级属性</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">deepClone</span>(<span class="params">obj</span>) </span>{</span><br><span class="line"> <span class="keyword">let</span> objClone = <span class="built_in">Array</span>.isArray(obj) ? [] : {};</span><br><span class="line"> <span class="keyword">if</span>(obj && <span class="keyword">typeof</span> obj === <span class="string">“object”</span>) {</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">var</span> key <span class="keyword">in</span> obj) {</span><br><span class="line"> <span class="keyword">if</span>(obj.hasOwnProperty(key)) {</span><br><span class="line"> <span class="comment">//判断ojb子元素是否为对象,如果是,递归复制</span></span><br><span class="line"> <span class="keyword">if</span>(obj[key] && <span class="keyword">typeof</span> obj[key] === <span class="string">“object”</span>) {</span><br><span class="line"> objClone[key] = deepClone(obj[key]);</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="comment">//如果不是,简单复制</span></span><br><span class="line"> objClone[key] = obj[key];</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="keyword">return</span> obj;</span><br><span class="line"> } </span><br><span class="line"> <span class="keyword">return</span> objClone;</span><br><span class="line">} </span><br></pre></td></tr></table></figure><p></p></div><div class="note warning"><p>使用复制代码时,请将代码中的中文双引号替换为英文引号。</p></div><br>5.<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a = <span class="number">10</span>;</span><br><span class="line"><span class="keyword">var</span> b = <span class="number">20</span>;</span><br><span class="line"><span class="keyword">var</span> obj = {</span><br><span class="line"> a: <span class="number">30</span>,</span><br><span class="line"> b: <span class="keyword">this</span>.a + <span class="number">40</span>,</span><br><span class="line"> foo: <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>{ </span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">this</span>.a; </span><br><span class="line"> },</span><br><span class="line"> bar: <span class="function"><span class="params">()</span> =></span> <span class="keyword">this</span>.a ,</span><br><span class="line"> baz: <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{ </span><br><span class="line"> <span class="function"><span class="keyword">function</span> <span class="title">abc</span>(<span class="params"></span>) </span>{ </span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">this</span>.b;</span><br><span class="line"> } </span><br><span class="line"> abc(); </span><br><span class="line"> },</span><br><span class="line">}</span><br></pre></td></tr></table></figure>以上代码运行后,则<code>obj.b</code> = __________,<code>obj.foo()</code>的返回值为 __________,<div class="note info"><h3>答案:50、30</h3></div>执行了<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> test = obj.foo;</span><br></pre></td></tr></table></figure>后,<code>test()</code>的返回值为__________,<code>obj.bar()</code>的返回值为__________,<code>obj.baz()</code>的返回值为__________。<div class="note info"><h3>答案:10、10、undefined</h3></div><div class="note warning"><p>关于js中<code>this</code>的讲解,可以参照<a href="https://www.jianshu.com/p/d647aa6d1ae6" target="_blank" rel="noopener">这波能反杀的个人博客</a>。</p></div><br>6.实现一个add方法,使计算结果能够满足如下预期:<br><code>add(1, 2, 3) = 6</code><br><code>add(1, 2, 3)(4) = 10</code><br><code>add(1)(2)(3)(4)(5) = 15</code><div class="note info"><p></p><h3>答案:如下方代码段所示</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> add = <span class="function">(<span class="params">…args</span>) =></span> { </span><br><span class="line"> <span class="keyword">const</span> _add = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>{ </span><br><span class="line"> args.push(…arguments); </span><br><span class="line"> <span class="keyword">return</span> _add;</span><br><span class="line"> }</span><br><span class="line"> _add.toString = <span class="function"><span class="params">()</span> =></span> {</span><br><span class="line"> <span class="keyword">return</span> args.reduce( <span class="function">(<span class="params">a, b</span>) =></span> a + b );</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> _add;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p></p></div><br>7.说说你了解的<code>Promise</code>。<br><div class="note info"><h3><code>Promise</code>是一种异步机制,主要是用来解决回调地狱的问题。<code>Promise</code>对象有三种状态,分别是<code>pending</code>、<code>resolved</code>、<code>rejected</code>;在<code>Promise</code>对象的构造函数中,接收<code>resolve</code>和<code>reject</code>函数修改状态;<code>Promise</code>对象中的<code>then</code>方法,可以接收构造函数中处理的状态变化,并分别对应执行。<code>then</code>方法的执行结果也会返回一个<code>Promise</code>对象,因此可以进行<code>then</code>的链式执行,这也是解决回调地狱的主要方式。</h3></div><p></p><h2 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h2><ol><li>题目中出现的JS指的是采用ECMAScript 2015及之后标准的JavaScript</li></ol><ol start="2"><li><p>答案中,若有错误和需完善的地方,可在下方留言反馈哈~~</p></li><li><p>查看纯习题版,请点击<a href="/jsexer13.html" title="js基础练习题 第13天">js基础练习题 第13天</a></p></li></ol></div><div><div><div style="text-align:center;color:#ccc;font-size:14px;letter-spacing:.2rem">--本文结束 <i class="fa fa-heart"></i> 感谢阅读--</div></div></div><div><div style="padding:10px 0;margin:20px auto;width:90%;text-align:center"><div>创作十分不易,原创更应鼓励</div><button id="rewardButton" disable="enable" onclick='var e=document.getElementById("QR");"none"===e.style.display?e.style.display="block":e.style.display="none"'><span>打赏</span></button><div id="QR" style="display:none"><div id="wechat" style="display:inline-block"><img id="wechat_qr" src="/images/wechatpay.png" alt="jealyn.wang 微信支付"><p>微信支付</p></div><div id="alipay" style="display:inline-block"><img id="alipay_qr" src="/images/alipay.png" alt="jealyn.wang 支付宝"><p>支付宝</p></div></div></div></div><div><ul class="post-copyright"><li class="post-copyright-author"><strong>本文作者:</strong> jealyn.wang</li><li class="post-copyright-link"><strong>本文链接:</strong> <a href="https://www.jealyn.top/jsexer13-ans.html" title="js练习题第13天 答案及解析">https://www.jealyn.top/jsexer13-ans.html</a></li><li class="post-copyright-license"><strong>版权声明: </strong>本博客所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处!</li></ul></div><footer class="post-footer"><div class="post-tags"><a href="/tags/数据类型/" rel="tag"><i class="fa fa-tag"></i> 数据类型</a> <a href="/tags/javascript/" rel="tag"><i class="fa fa-tag"></i> javascript</a> <a href="/tags/web前端/" rel="tag"><i class="fa fa-tag"></i> web前端</a> <a href="/tags/前端面试题/" rel="tag"><i class="fa fa-tag"></i> 前端面试题</a> <a href="/tags/柯里化/" rel="tag"><i class="fa fa-tag"></i> 柯里化</a> <a href="/tags/Promise/" rel="tag"><i class="fa fa-tag"></i> Promise</a></div><div class="post-nav"><div class="post-nav-next post-nav-item"><a href="/jsexer13.html" rel="next" title="js基础练习题 第13天"><i class="fa fa-chevron-left"></i> js基础练习题 第13天</a></div><span class="post-nav-divider"></span><div class="post-nav-prev post-nav-item"><a href="/jsexer14.html" rel="prev" title="js基础练习题 第14天">js基础练习题 第14天 <i class="fa fa-chevron-right"></i></a></div></div></footer></div></article><div class="post-spread"></div></div></div><div class="comments" id="comments"><div id="lv-container" data-id="city" data-uid="MTAyMC80Mjk1MS8xOTQ5Nw=="></div></div></div><div class="sidebar-toggle"><div class="sidebar-toggle-line-wrap"><span class="sidebar-toggle-line sidebar-toggle-line-first"></span> <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span> <span class="sidebar-toggle-line sidebar-toggle-line-last"></span></div></div><aside id="sidebar" class="sidebar"><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">文章目录</li><li class="sidebar-nav-overview" data-target="site-overview-wrap">站点概览</li></ul><section class="site-overview-wrap sidebar-panel"><div class="site-overview"><div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person"><img class="site-author-image" itemprop="image" src="/images/avatar.png" alt="jealyn.wang"><p class="site-author-name" itemprop="name">jealyn.wang</p><p class="site-description motion-element" itemprop="description">前端小白一枚</p></div><nav class="site-state motion-element"><div class="site-state-item site-state-posts"><a href="/archives/"><span class="site-state-item-count">85</span> <span class="site-state-item-name">日志</span></a></div><div class="site-state-item site-state-categories"><a href="/categories/index.html"><span class="site-state-item-count">6</span> <span class="site-state-item-name">分类</span></a></div><div class="site-state-item site-state-tags"><a href="/tags/index.html"><span class="site-state-item-count">58</span> <span class="site-state-item-name">标签</span></a></div></nav><div class="links-of-author motion-element"><span class="links-of-author-item"><a href="https://github.com/jealyn" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i>GitHub</a> </span><span class="links-of-author-item"><a href="mailto:[email protected]" target="_blank" title="Email"><i class="fa fa-fw fa-envelope"></i>Email</a> </span><span class="links-of-author-item"><a href="https://www.zhihu.com/people/wang-jin-lin-49-35/activities" target="_blank" title="知乎"><i class="fa fa-fw fa-comments"></i>知乎</a> </span><span class="links-of-author-item"><a href="https://me.csdn.net/qq_30216191" target="_blank" title="CSDN"><i class="fa fa-fw fa-edit"></i>CSDN</a></span></div><div class="links-of-blogroll motion-element links-of-blogroll-inline"><div class="links-of-blogroll-title"><i class="fa fa-fw fa-link"></i> 友情链接</div><ul class="links-of-blogroll-list"><li class="links-of-blogroll-item"><a href="https://hexo.io/zh-cn/docs/index.html" title="Hexo文档" target="_blank">Hexo文档</a></li><li class="links-of-blogroll-item"><a href="http://www.ruanyifeng.com/home.html" title="阮一峰的个人网站" target="_blank">阮一峰的个人网站</a></li><li class="links-of-blogroll-item"><a href="https://www.jianshu.com/u/10ae59f49b13" title="这波能反杀" target="_blank">这波能反杀</a></li><li class="links-of-blogroll-item"><a href="https://www.yangqq.com/" title="杨青个人博客" target="_blank">杨青个人博客</a></li><li class="links-of-blogroll-item"><a href="https://blog.csdn.net/qq_30216191" title="Jealyn的个人博客" target="_blank">Jealyn的个人博客</a></li></ul></div></div></section><section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active"><div class="post-toc"><div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#正文"><span class="nav-number">1.</span> <span class="nav-text">正文</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.1.</span> <span class="nav-text">答案:在js中一共有7种基本数据类型,分别是number, string, boolean, null, undefined, symbol, bigint</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.2.</span> <span class="nav-text">答案:在js中一共有3种引用数据类型,分别是object、array、function</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.3.</span> <span class="nav-text">从数据存储上来说,基本数据类型的名(key)和值(value)都存储在栈内存中;而引用数据类型的名存在栈内存中,值存在于堆内存中,栈内存会提供一个引用的地址(指针)指向堆内存中的值。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.4.</span> <span class="nav-text">浅拷贝是对栈内存中的值(即指针)的拷贝,拷贝前后对象指向的是堆内存中的同一个值;深拷贝是指在堆内存中开辟一个新的内存专门来存放拷贝值,此时拷贝后的值与原值就是相互独立、互不影响的。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.5.</span> <span class="nav-text">答案:50、30</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.6.</span> <span class="nav-text">答案:10、10、undefined</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.7.</span> <span class="nav-text">答案:如下方代码段所示</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.8.</span> <span class="nav-text">Promise是一种异步机制,主要是用来解决回调地狱的问题。Promise对象有三种状态,分别是pending、resolved、rejected;在Promise对象的构造函数中,接收resolve和reject函数修改状态;Promise对象中的then方法,可以接收构造函数中处理的状态变化,并分别对应执行。then方法的执行结果也会返回一个Promise对象,因此可以进行then的链式执行,这也是解决回调地狱的主要方式。</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#说明"><span class="nav-number">2.</span> <span class="nav-text">说明</span></a></li></ol></div></div></section></div></aside></div></main><footer id="footer" class="footer"><div class="footer-inner"><div class="copyright">© <span itemprop="copyrightYear">2019</span> <span class="with-love"><i class="fa fa-user"></i> </span><span class="author" itemprop="copyrightHolder">jealyn.wang</span></div><div class="busuanzi-count"><script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span class="site-uv">访客数 <i class="fa fa-user"></i> <span class="busuanzi-value" id="busuanzi_value_site_uv"></span> 人 </span><span class="site-pv">浏览数 <i class="fa fa-eye"></i> <span class="busuanzi-value" id="busuanzi_value_site_pv"></span> 次</span></div></div></footer><div class="back-to-top"><i class="fa fa-arrow-up"></i></div></div><script type="text/javascript">"[object Function]"!==Object.prototype.toString.call(window.Promise)&&(window.Promise=null)</script><script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script><script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script><script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script><script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script><script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script><script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script><script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script><script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script><script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script><script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script><script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script><script type="text/javascript">!function(e,t){var n,c=e.getElementsByTagName(t)[0];"function"!=typeof LivereTower&&(n=e.createElement(t),n.src="https://cdn-city.livere.com/js/embed.dist.js",n.async=!0,c.parentNode.insertBefore(n,c))}(document,"script")</script><script type="text/javascript">function proceedsearch(){$("body").append('<div class="search-popup-overlay local-search-pop-overlay"></div>').css("overflow","hidden"),$(".search-popup-overlay").click(onPopupClose),$(".popup").toggle();var t=$("#local-search-input");t.attr("autocapitalize","none"),t.attr("autocorrect","off"),t.focus()}var isfetched=!1,isXml=!0,search_path="search.xml";0===search_path.length?search_path="search.xml":/json$/i.test(search_path)&&(isXml=!1);var path="/"+search_path,onPopupClose=function(t){$(".popup").hide(),$("#local-search-input").val(""),$(".search-result-list").remove(),$("#no-result").remove(),$(".local-search-pop-overlay").remove(),$("body").css("overflow","")},searchFunc=function(t,e,o){"use strict";$("body").append('<div class="search-popup-overlay local-search-pop-overlay"><div id="search-loading-icon"><i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i></div></div>').css("overflow","hidden"),$("#search-loading-icon").css("margin","20% auto 0 auto").css("text-align","center"),$.ajax({url:t,dataType:isXml?"xml":"json",async:!0,success:function(t){isfetched=!0,$(".popup").detach().appendTo(".header-inner");var n=isXml?$("entry",t).map(function(){return{title:$("title",this).text(),content:$("content",this).text(),url:$("url",this).text()}}).get():t,r=document.getElementById(e),s=document.getElementById(o),a=function(){var t=r.value.trim().toLowerCase(),e=t.split(/[\s\-]+/);e.length>1&&e.push(t);var o=[];if(t.length>0&&n.forEach(function(n){function r(e,o,n,r){for(var s=r[r.length-1],a=s.position,i=s.word,l=[],h=0;a+i.length<=n&&0!=r.length;){i===t&&h++,l.push({position:a,length:i.length});var p=a+i.length;for(r.pop();0!=r.length&&(s=r[r.length-1],a=s.position,i=s.word,p>a);)r.pop()}return c+=h,{hits:l,start:o,end:n,searchTextCount:h}}function s(t,e){var o="",n=e.start;return e.hits.forEach(function(e){o+=t.substring(n,e.position);var r=e.position+e.length;o+='<b class="search-keyword">'+t.substring(e.position,r)+"</b>",n=r}),o+=t.substring(n,e.end)}var a=!1,i=0,c=0,l=n.title.trim(),h=l.toLowerCase(),p=n.content.trim().replace(/<[^>]+>/g,""),u=p.toLowerCase(),f=decodeURIComponent(n.url),d=[],g=[];if(""!=l&&(e.forEach(function(t){function e(t,e,o){var n=t.length;if(0===n)return[];var r=0,s=[],a=[];for(o||(e=e.toLowerCase(),t=t.toLowerCase());(s=e.indexOf(t,r))>-1;)a.push({position:s,word:t}),r=s+n;return a}d=d.concat(e(t,h,!1)),g=g.concat(e(t,u,!1))}),(d.length>0||g.length>0)&&(a=!0,i=d.length+g.length)),a){[d,g].forEach(function(t){t.sort(function(t,e){return e.position!==t.position?e.position-t.position:t.word.length-e.word.length})});var v=[];0!=d.length&&v.push(r(l,0,l.length,d));for(var $=[];0!=g.length;){var C=g[g.length-1],m=C.position,x=C.word,w=m-20,y=m+80;0>w&&(w=0),y<m+x.length&&(y=m+x.length),y>p.length&&(y=p.length),$.push(r(p,w,y,g))}$.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hits.length!==e.hits.length?e.hits.length-t.hits.length:t.start-e.start});var T=parseInt("1");T>=0&&($=$.slice(0,T));var b="";b+=0!=v.length?"<li><a href='"+f+"' class='search-result-title'>"+s(l,v[0])+"</a>":"<li><a href='"+f+"' class='search-result-title'>"+l+"</a>",$.forEach(function(t){b+="<a href='"+f+'\'><p class="search-result">'+s(p,t)+"...</p></a>"}),b+="</li>",o.push({item:b,searchTextCount:c,hitCount:i,id:o.length})}}),1===e.length&&""===e[0])s.innerHTML='<div id="no-result"><i class="fa fa-search fa-5x" /></div>';else if(0===o.length)s.innerHTML='<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>';else{o.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hitCount!==e.hitCount?e.hitCount-t.hitCount:e.id-t.id});var a='<ul class="search-result-list">';o.forEach(function(t){a+=t.item}),a+="</ul>",s.innerHTML=a}};r.addEventListener("input",a),$(".local-search-pop-overlay").remove(),$("body").css("overflow",""),proceedsearch()}})};$(".popup-trigger").click(function(t){t.stopPropagation(),isfetched===!1?searchFunc(path,"local-search-input","local-search-result"):proceedsearch()}),$(".popup-btn-close").click(onPopupClose),$(".popup").click(function(t){t.stopPropagation()}),$(document).on("keyup",function(t){var e=27===t.which&&$(".search-popup").is(":visible");e&&onPopupClose()})</script><script>!function(){var t=document.createElement("script"),s=window.location.protocol.split(":")[0];"https"===s?t.src="https://zz.bdstatic.com/linksubmit/push.js":t.src="http://push.zhanzhang.baidu.com/push.js";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e)}()</script><script type="text/javascript" src="https://jealyn-1258764186.cos.ap-chengdu.myqcloud.com/love.js"></script><script type="text/javascript" src="https://jealyn-1258764186.cos.ap-chengdu.myqcloud.com/clipboard.min.js"></script><script type="text/javascript" src="https://jealyn-1258764186.cos.ap-chengdu.myqcloud.com/clipboard-use.js"></script></body></html><!-- rebuild by neat -->