文章列表


<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,常用于前后端之间的数据传输。JSON 的书写格式主要有以下几种:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">对象格式(Object)</p><pre class="brush:as3;toolbar:false">{ &nbsp;&nbsp;&quot;name&quot;:&nbsp;&quot;John&quot;, &nbsp;&nbsp;&quot;age&quot;:&nbsp;30, &nbsp;&nbsp;&quot;isStudent&quot;:&nbsp;true, &nbsp;&nbsp;&quot;hobbies&quot;:&nbsp;[&quot;reading&quot;,&nbsp;&quot;running&quot;,&nbsp;&quot;swimming&quot;], &nbsp;&nbsp;&quot;address&quot;:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&quot;street&quot;:&nbsp;&quot;123&nbsp;Main&nbsp;St&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&quot;city&quot;:&nbsp;&quot;New&nbsp;York&quot;, &nbsp;&nbsp;&nbsp;&nbsp;&quot;country&quot;:&nbsp;&quot;USA&quot; &nbsp;&nbsp;} }</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">数组格式(Array)</p><pre class="brush:as3;toolbar:false">[&nbsp;&nbsp;&quot;apple&quot;,&nbsp;&nbsp;&quot;banana&quot;,&nbsp;&nbsp;&quot;orange&quot;,&nbsp;&nbsp;&quot;grape&quot;]</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">值格式(Value)</p><pre class="brush:as3;toolbar:false">&quot;Hello,&nbsp;World!&quot;</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">空值格式(Null)</p><pre class="brush:as3;toolbar:false">null</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">JSON <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">数据格式的优点包括:易于阅读和编写,易于解析和生成,支持多种编程语言。在</span> Web <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">开发中,我们通常会使用</span> JavaScript <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">的</span> JSON.parse() <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">方法将</span> JSON <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">数据转换为对象格式,使用</span> JSON.stringify() <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">方法将</span> JavaScript <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">对象转换为</span> JSON <span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;PingFang SC&quot;;">数据格式。</span></p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Webpack 是一个强大的打包工具,可以帮助我们将多个模块打包成一个或多个 JavaScript 文件。下面是一个基本的 Webpack 配置示例,可以用于构建一个简单的 JavaScript 项目:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 16px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">安装 Webpack 和相关依赖</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在项目的根目录下打开命令行窗口,执行以下命令来安装 Webpack 和相关依赖:</p><pre class="brush:as3;toolbar:false">npm&nbsp;install&nbsp;webpack&nbsp;webpack-cli&nbsp;webpack-dev-server&nbsp;html-webpack-plugin&nbsp;--save-dev</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">其中,webpack 是 Webpack 的核心依赖,webpack-cli 是 Webpack 的命令行工具,webpack-dev-server 是 Webpack 的开发服务器,html-webpack-plugin 是 Webpack 的 HTML 模板插件。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 16px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">创建 Webpack 配置文件</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在项目的根目录下创建一个名为 webpack.config.js 的文件,然后添加以下代码:</p><pre class="brush:as3;toolbar:false">const&nbsp;path&nbsp;=&nbsp;require(&#39;path&#39;); const&nbsp;HtmlWebpackPlugin&nbsp;=&nbsp;require(&#39;html-webpack-plugin&#39;); module.exports&nbsp;=&nbsp;{ &nbsp;&nbsp;entry:&nbsp;&#39;./src/index.js&#39;,&nbsp;//&nbsp;入口文件 &nbsp;&nbsp;output:&nbsp;{&nbsp;//&nbsp;输出文件 &nbsp;&nbsp;&nbsp;&nbsp;path:&nbsp;path.resolve(__dirname,&nbsp;&#39;dist&#39;), &nbsp;&nbsp;&nbsp;&nbsp;filename:&nbsp;&#39;bundle.js&#39; &nbsp;&nbsp;}, &nbsp;&nbsp;module:&nbsp;{&nbsp;//&nbsp;模块配置 &nbsp;&nbsp;&nbsp;&nbsp;rules:&nbsp;[ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test:&nbsp;/\.js$/,&nbsp;//&nbsp;匹配&nbsp;JavaScript&nbsp;文件 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exclude:&nbsp;/node_modules/,&nbsp;//&nbsp;排除&nbsp;node_modules&nbsp;目录 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loader:&nbsp;&#39;babel-loader&#39;&nbsp;//&nbsp;使用&nbsp;babel-loader&nbsp;处理&nbsp;JavaScript&nbsp;文件 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;] &nbsp;&nbsp;}, &nbsp;&nbsp;plugins:&nbsp;[&nbsp;//&nbsp;插件配置 &nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;HtmlWebpackPlugin({ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template:&nbsp;&#39;./src/index.html&#39;&nbsp;//&nbsp;使用&nbsp;index.html&nbsp;作为&nbsp;HTML&nbsp;模板 &nbsp;&nbsp;&nbsp;&nbsp;}) &nbsp;&nbsp;], &nbsp;&nbsp;devServer:&nbsp;{&nbsp;//&nbsp;开发服务器配置 &nbsp;&nbsp;&nbsp;&nbsp;contentBase:&nbsp;&#39;./dist&#39;&nbsp;//&nbsp;设置服务器的根目录为&nbsp;dist&nbsp;目录 &nbsp;&nbsp;} };</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的代码中,entry 指定了入口文件,output 指定了输出文件,module.rules 定义了如何处理 JavaScript 文件,plugins 配置了 Webpack 的插件,devServer 配置了 Webpack 的开发服务器。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 16px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">创建 Babel 配置文件</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在项目的根目录下创建一个名为 .babelrc 的文件,然后添加以下代码:</p><pre class="brush:as3;toolbar:false">{ &nbsp;&nbsp;&quot;presets&quot;:&nbsp;[&quot;@babel/preset-env&quot;] }</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的代码指定了使用 @babel/preset-env 来处理 JavaScript 文件。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 16px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">创建 JavaScript 文件和 HTML 文件</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在 src 目录下创建一个名为 index.js 的文件,然后添加以下代码:</p><pre class="brush:as3;toolbar:false">const&nbsp;sum&nbsp;=&nbsp;(a,&nbsp;b)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;return&nbsp;a&nbsp;+&nbsp;b; }; console.log(sum(1,&nbsp;2));</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在 src 目录下创建一个名为 index.html 的文件,然后添加以下代码:</p><pre class="brush:as3;toolbar:false">&lt;!DOCTYPE&nbsp;html&gt; &lt;html&gt; &nbsp;&nbsp;&lt;head&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;meta&nbsp;charset=&quot;utf-8&quot;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;Webpack&nbsp;Demo&lt;/title&gt; &nbsp;&nbsp;&lt;/head&gt; &nbsp;&nbsp;&lt;body&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;script&nbsp;src=&quot;bundle.js&quot;&gt;&lt;/script&gt; &nbsp;&nbsp;&lt;/body&gt; &lt;/html&gt;</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">执行打包命令</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在命令行中执行以下命令来启动 Webpack 开发服务器:</p><pre class="brush:as3;toolbar:false">npx&nbsp;webpack&nbsp;serve&nbsp;--mode&nbsp;development</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">执行完成后,可以在浏览器中打开 http://localhost:8080 来查看项目效果。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 16px; white-space: normal;"><br/></p><p class="p3" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: &quot;PingFang SC&quot;; white-space: normal;">以上是一个基本的<span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;Helvetica Neue&quot;;"> Webpack </span>配置示例,你可以根据项目需要进行相应的修改和扩展。</p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Webpack 是一种模块化打包工具,可以将多个 JavaScript 文件打包成一个或多个文件,以便在浏览器中加载。Babel 是一种 JavaScript 编译器,可以将 ES6 语法转换成浏览器可以支持的 ES5 语法。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Webpack 和 Babel 的结合使用,可以实现将 ES6 语法转换成浏览器可以支持的 ES5 语法,并将多个 JavaScript 文件打包成一个或多个文件的功能。下面是使用 Webpack 和 Babel 的一些常见步骤:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">安装 Webpack 和 Babel</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在命令行中使用以下命令安装 Webpack 和 Babel:</p><pre class="brush:as3;toolbar:false">npm&nbsp;install&nbsp;webpack&nbsp;webpack-cli&nbsp;babel-loader&nbsp;@babel/core&nbsp;@babel/preset-env&nbsp;--save-dev</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">创建 Webpack 配置文件</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在项目根目录下创建一个名为 webpack.config.js 的文件,然后添加以下代码:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><pre class="brush:as3;toolbar:false">const&nbsp;path&nbsp;=&nbsp;require(&#39;path&#39;); module.exports&nbsp;=&nbsp;{ &nbsp;&nbsp;entry:&nbsp;&#39;./src/index.js&#39;, &nbsp;&nbsp;output:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;path:&nbsp;path.resolve(__dirname,&nbsp;&#39;dist&#39;), &nbsp;&nbsp;&nbsp;&nbsp;filename:&nbsp;&#39;bundle.js&#39; &nbsp;&nbsp;}, &nbsp;&nbsp;module:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;rules:&nbsp;[ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test:&nbsp;/\.js$/, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exclude:&nbsp;/node_modules/, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;use:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loader:&nbsp;&#39;babel-loader&#39;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options:&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;presets:&nbsp;[&#39;@babel/preset-env&#39;] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;] &nbsp;&nbsp;} };</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的代码指定了入口文件(entry)、输出文件(output)以及如何处理 JavaScript 文件(module.rules)。其中使用 babel-loader 和 @babel/preset-env 来处理 JavaScript 文件。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">创建 Babel 配置文件</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在项目根目录下创建一个名为 .babelrc 的文件,然后添加以下代码:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><pre class="brush:as3;toolbar:false">{ &nbsp;&nbsp;&quot;presets&quot;:&nbsp;[&quot;@babel/preset-env&quot;] }</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的代码指定了使用 @babel/preset-env 来处理 JavaScript 文件。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">创建 JavaScript 文件</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在 src 目录下创建一个名为 index.js 的文件,然后添加以下代码:</p><pre class="brush:as3;toolbar:false">const&nbsp;sum&nbsp;=&nbsp;(a,&nbsp;b)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;return&nbsp;a&nbsp;+&nbsp;b; }; console.log(sum(1,&nbsp;2));</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的代码是一个使用 ES6 语法定义的函数。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">执行打包命令</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在命令行中使用以下命令来执行打包:</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">npx webpack --mode development</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的命令会执行 Webpack 的打包操作,并将打包结果输出到 dist 目录下的 bundle.js 文件中。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">执行完成后,可以在浏览器中打开 index.html 文件,并查看浏览器控制台的输出结果,应该可以看到 sum 函数的结果为 3。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p3" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;PingFang SC&quot;; white-space: normal;"><span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;Helvetica Neue&quot;;">Webpack </span>和<span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;Helvetica Neue&quot;;"> Babel </span>的结合使用可以帮助开发者在浏览器中使用<span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;Helvetica Neue&quot;;"> ES6 </span>语法,提高开发效率和代码质量。</p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">ES6 中的 Promise 是一种处理异步操作的机制,它可以避免回调地狱,使得异步代码更加易读和可维护。下面是如何运用 ES6 Promise 进行异步编程的一些常见方式:</p><pre class="brush:as3;toolbar:false">Promise.resolve()&nbsp;和&nbsp;Promise.reject() Promise.resolve()&nbsp;和&nbsp;Promise.reject()&nbsp;是两个常用的静态方法,它们可以用来快速地创建一个已经成功或已经失败的&nbsp;Promise&nbsp;对象。比如: const&nbsp;p1&nbsp;=&nbsp;Promise.resolve(&#39;成功&#39;); const&nbsp;p2&nbsp;=&nbsp;Promise.reject(&#39;失败&#39;);</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise.then() 和 Promise.catch()</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise.then() 方法用来处理 Promise 对象的成功情况,Promise.catch() 方法用来处理 Promise 对象的失败情况。可以通过链式调用的方式来处理 Promise 对象的结果,比如:</p><pre class="brush:as3;toolbar:false">const&nbsp;p&nbsp;=&nbsp;new&nbsp;Promise((resolve,&nbsp;reject)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;//&nbsp;异步操作 &nbsp;&nbsp;setTimeout(()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;result&nbsp;=&nbsp;Math.random()&nbsp;&lt;&nbsp;0.5&nbsp;?&nbsp;&#39;成功&#39;&nbsp;:&nbsp;&#39;失败&#39;; &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(result&nbsp;===&nbsp;&#39;成功&#39;)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resolve(result); &nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reject(result); &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;},&nbsp;1000); }); p.then((result)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;console.log(result);&nbsp;//&nbsp;处理成功的情况 }).catch((result)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;console.log(result);&nbsp;//&nbsp;处理失败的情况 });</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise.all()</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise.all() 方法可以同时处理多个 Promise 对象,等待所有 Promise 对象都完成后,再将它们的结果按照顺序依次返回。如果其中任何一个 Promise 对象失败了,则整个 Promise.all() 也会失败。比如:</p><pre class="brush:as3;toolbar:false">const&nbsp;p1&nbsp;=&nbsp;Promise.resolve(&#39;第一个&nbsp;Promise&nbsp;对象&#39;); const&nbsp;p2&nbsp;=&nbsp;Promise.resolve(&#39;第二个&nbsp;Promise&nbsp;对象&#39;); const&nbsp;p3&nbsp;=&nbsp;Promise.reject(&#39;第三个&nbsp;Promise&nbsp;对象&#39;); Promise.all([p1,&nbsp;p2,&nbsp;p3]) &nbsp;&nbsp;.then((results)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log(results);&nbsp;//&nbsp;[&nbsp;&#39;第一个&nbsp;Promise&nbsp;对象&#39;,&nbsp;&#39;第二个&nbsp;Promise&nbsp;对象&#39;,&nbsp;&#39;第三个&nbsp;Promise&nbsp;对象&#39;&nbsp;] &nbsp;&nbsp;}) &nbsp;&nbsp;.catch((error)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log(error);&nbsp;//&nbsp;第三个&nbsp;Promise&nbsp;对象 &nbsp;&nbsp;});</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise.race()</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise.race() 方法可以同时处理多个 Promise 对象,等待其中任何一个 Promise 对象完成后,就将它的结果返回。如果其中任何一个 Promise 对象失败了,则整个 Promise.race() 也会失败。比如:</p><pre class="brush:as3;toolbar:false">const&nbsp;p1&nbsp;=&nbsp;new&nbsp;Promise((resolve)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;setTimeout(()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;resolve(&#39;第一个&nbsp;Promise&nbsp;对象&#39;); &nbsp;&nbsp;},&nbsp;1000); }); const&nbsp;p2&nbsp;=&nbsp;new&nbsp;Promise((resolve)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;setTimeout(()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;resolve(&#39;第二个&nbsp;Promise&nbsp;对象&#39;); &nbsp;&nbsp;},&nbsp;500); }); Promise.race([p1,&nbsp;p2]) &nbsp;&nbsp;.then((result)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log(result);&nbsp;//&nbsp;第二个&nbsp;Promise&nbsp;对象 &nbsp;&nbsp;}) &nbsp;&nbsp;.catch((error)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log(error); &nbsp;&nbsp;});</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">综上所述,ES6 Promise 提供了一种优雅和灵活的方式来处理异步编程,可以提高代码质量和开发效率。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">ES6(ECMAScript 2015)是 JavaScript 的一个版本,它在语言层面上新增了许多有用的特性,包括 Promise 和 Class 类两个重要的概念。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise 是一种处理异步操作的机制,它可以避免回调地狱,使得异步代码更加易读和可维护。Promise 对象代表了一个异步操作的最终完成(或失败)以及其结果值的表示。Promise 对象有三个状态:pending(进行中)、fulfilled(已成功)和rejected(已失败)。使用 Promise 可以通过链式调用的方式处理异步操作的结果,从而避免回调地狱的问题。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Class 类</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">ES6 中新增了 Class 类的概念,它是一种用来创建对象的模板,提供了更加优雅和灵活的面向对象编程方式。Class 类可以看作是构造函数的一种语法糖,它包含了构造函数、原型和实例对象三部分。Class 类中可以定义构造函数、实例方法、静态方法和访问器等内容,而这些内容在传统的构造函数中需要通过 prototype 来定义。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Class 类与传统的构造函数相比,有以下优点:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">更加易读和易于维护:Class 类提供了更加优雅和灵活的面向对象编程方式,可以使代码更加清晰易懂,更易于维护。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">继承更加简单:Class 类提供了更加简单和易于理解的继承方式,可以通过 extends 关键字来实现继承。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">更加严谨和安全:Class 类的定义和使用都更加严谨和安全,可以减少一些常见的错误和问题。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">综上所述,Promise 和 Class 类是 ES6 中两个重要的概念,它们为 JavaScript 编程提供了更加优雅和灵活的方式,可以提高开发效率和代码质量。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p><br/></p>

<p>ES6(ECMAScript 2015)是 JavaScript 的一个版本,它在语言层面上新增了许多有用的特性,包括许多新的方法,这些方法为 JavaScript 编程提供了更多的便利。下面是 ES6 中新增的一些方法:</p><p><br/></p><p>Array.from():将类似数组的对象或可迭代对象转换为数组。</p><p>Array.of():创建一个包含任意数量参数的新数组。</p><p>Array.prototype.find():返回数组中满足指定条件的第一个元素。</p><p>Array.prototype.findIndex():返回数组中满足指定条件的第一个元素的下标。</p><p>Array.prototype.fill():用指定的值填充数组。</p><p>Array.prototype.copyWithin():将数组中指定的元素复制到指定位置,覆盖原有元素。</p><p>String.prototype.startsWith():判断一个字符串是否以指定字符串开头。</p><p>String.prototype.endsWith():判断一个字符串是否以指定字符串结尾。</p><p>String.prototype.includes():判断一个字符串是否包含指定字符串。</p><p>String.prototype.repeat():返回一个由指定字符串重复指定次数的新字符串。</p><p>String.prototype.padStart():用指定的字符串填充一个字符串,使其达到指定的长度。</p><p>String.prototype.padEnd():用指定的字符串填充一个字符串,使其达到指定的长度。</p><p>Object.assign():将一个或多个对象的属性拷贝到目标对象中。</p><p>Object.keys():返回一个包含所有可枚举属性名称的数组。</p><p>Object.values():返回一个包含所有可枚举属性值的数组。</p><p>Object.entries():返回一个包含所有可枚举属性键值对的数组。</p><p>这些方法为 JavaScript 编程提供了更多的便利,可以更加高效地处理各种数据和对象,从而提高了开发效率和代码质量。</p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">ES6(ECMAScript 2015)是 JavaScript 的一个版本,它在语言层面上新增了许多有用的特性,包括一些新的数据结构,这些数据结构提供了更好的性能和更多的功能。下面是 ES6 中新增的一些数据结构:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Map:一种有序的键值对集合,其中的键可以是任意类型,而不仅仅是字符串类型。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Set:一种无序的、不重复的值的集合,其中的元素可以是任意类型。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">WeakMap:一种只能使用对象作为键的 Map,键被弱引用,当键所对应的对象被垃圾回收时,该键也会自动被移除。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">WeakSet:一种只能存储对象的 Set,元素被弱引用,当元素所对应的对象被垃圾回收时,该元素也会自动被移除。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Symbol:一种原始数据类型,表示独一无二的值,主要用于对象属性的命名和保护。</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">Promise:一种处理异步操作的机制,可以避免回调地狱,使得异步代码更加易读和可维护。</p><p class="p3" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;PingFang SC&quot;; white-space: normal;">这些数据结构都是在<span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;Helvetica Neue&quot;;"> ES6 </span>中新增的,它们的引入使得<span class="s1" style="font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; line-height: normal; font-family: &quot;Helvetica Neue&quot;;"> JavaScript </span>的功能更加完善,可以更加高效地处理各种数据结构,从而提高了开发效率和代码质量。</p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">JavaScript 对象字面量是一种更加简洁、灵活的表达方式,可以方便地创建一个对象并为其赋值属性。对象字面量可以通过花括号({})来定义一个对象,其中可以包含多个属性及其对应的值,属性名和值之间使用冒号(:)分隔,每个属性之间使用逗号(,)分隔。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">下面是一个简单的示例:</p><pre class="brush:as3;toolbar:false">const&nbsp;person&nbsp;=&nbsp;{ &nbsp;&nbsp;name:&nbsp;&#39;Tom&#39;, &nbsp;&nbsp;age:&nbsp;18, &nbsp;&nbsp;gender:&nbsp;&#39;male&#39; };</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">上面的代码创建了一个名为 person 的对象,并为其定义了三个属性:name、age 和 gender。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">除了基本属性值之外,对象字面量还支持在属性值中定义函数,这样就可以定义对象的方法。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;person&nbsp;=&nbsp;{ &nbsp;&nbsp;name:&nbsp;&#39;Tom&#39;, &nbsp;&nbsp;age:&nbsp;18, &nbsp;&nbsp;gender:&nbsp;&#39;male&#39;, &nbsp;&nbsp;sayHello:&nbsp;function()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log(&#39;Hello,&nbsp;my&nbsp;name&nbsp;is&nbsp;&#39;&nbsp;+&nbsp;this.name); &nbsp;&nbsp;} }; person.sayHello();&nbsp;//&nbsp;输出&#39;Hello,&nbsp;my&nbsp;name&nbsp;is&nbsp;Tom&#39;</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在上面的代码中,我们为对象 person 定义了一个方法 sayHello(),用来输出该对象的名字。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">除此之外,对象字面量还支持动态属性名,可以使用中括号([])和表达式来定义属性名。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;propName&nbsp;=&nbsp;&#39;name&#39;; const&nbsp;person&nbsp;=&nbsp;{ &nbsp;&nbsp;[propName]:&nbsp;&#39;Tom&#39;, &nbsp;&nbsp;age:&nbsp;18, &nbsp;&nbsp;gender:&nbsp;&#39;male&#39; };</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在上面的代码中,我们使用变量 propName 的值作为属性名,从而实现了动态属性名的功能。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">对象字面量是一种非常常用的表达方式,尤其在创建简单的对象或配置对象时非常方便。它的灵活性也使得它可以轻松地创建动态的对象,从而实现更加复杂的功能。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在 JavaScript 中,可以使用对象和数组解构语法来自动解析数组或对象中的值。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">数组解构</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">对于数组,可以使用方括号([])和变量名来进行解构。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;arr&nbsp;=&nbsp;[1,&nbsp;2,&nbsp;3]; const&nbsp;[a,&nbsp;b,&nbsp;c]&nbsp;=&nbsp;arr; console.log(a);&nbsp;//&nbsp;输出1 console.log(b);&nbsp;//&nbsp;输出2 console.log(c);&nbsp;//&nbsp;输出3</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在上面的例子中,[a, b, c] = arr 表示将数组 arr 中的前三个元素依次赋值给变量 a、b 和 c。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在解构时,还可以使用默认值和剩余操作符(...)来进行处理。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;arr&nbsp;=&nbsp;[1,&nbsp;2]; const&nbsp;[a&nbsp;=&nbsp;0,&nbsp;b&nbsp;=&nbsp;0,&nbsp;...rest]&nbsp;=&nbsp;arr; console.log(a);&nbsp;//&nbsp;输出1 console.log(b);&nbsp;//&nbsp;输出2 console.log(rest);&nbsp;//&nbsp;输出[]</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在上面的例子中,a 和 b 都有默认值,如果对应的元素不存在,则会使用默认值。剩余操作符 ...rest 表示将剩余的元素都存储到 rest 变量中。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">对象解构</p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">对于对象,可以使用花括号({})和变量名来进行解构。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;obj&nbsp;=&nbsp;{&nbsp;name:&nbsp;&#39;Tom&#39;,&nbsp;age:&nbsp;18&nbsp;}; const&nbsp;{&nbsp;name,&nbsp;age&nbsp;}&nbsp;=&nbsp;obj; console.log(name);&nbsp;//&nbsp;输出&#39;Tom&#39; console.log(age);&nbsp;//&nbsp;输出18</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在上面的例子中,{ name, age } = obj 表示将对象 obj 中的属性 name 和 age 分别赋值给变量 name 和 age。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">同样的,对象解构也支持默认值和剩余操作符。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;obj&nbsp;=&nbsp;{&nbsp;name:&nbsp;&#39;Tom&#39;&nbsp;}; const&nbsp;{&nbsp;name,&nbsp;age&nbsp;=&nbsp;18,&nbsp;...rest&nbsp;}&nbsp;=&nbsp;obj; console.log(name);&nbsp;//&nbsp;输出&#39;Tom&#39; console.log(age);&nbsp;//&nbsp;输出18 console.log(rest);&nbsp;//&nbsp;输出{}</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">在上面的例子中,age 有默认值,如果 obj 中没有对应的属性,则会使用默认值。剩余操作符 ...rest 表示将剩余的属性都存储到 rest 变量中。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p3" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;PingFang SC&quot;; white-space: normal;">使用解构语法可以很方便地自动解析数组或对象中的值,使代码更加简洁易读。</p><p><br/></p>

<p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">箭头函数是ES6引入的新特性,它是一种更加简洁的函数定义方式,相比于传统函数,具有以下特点:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">箭头函数使用箭头(=&gt;)来定义,语法更加简洁。例如:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">// 传统函数定义方式</p><pre class="brush:as3;toolbar:false">function&nbsp;add(x,&nbsp;y)&nbsp;{ &nbsp;&nbsp;return&nbsp;x&nbsp;+&nbsp;y; } //&nbsp;箭头函数定义方式 const&nbsp;add&nbsp;=&nbsp;(x,&nbsp;y)&nbsp;=&gt;&nbsp;x&nbsp;+&nbsp;y;</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">箭头函数的this指向固定,不会因为调用方式的不同而改变。箭头函数的this指向定义时所在的上下文,而不是执行时的上下文。例如:</p><pre class="brush:as3;toolbar:false">const&nbsp;obj&nbsp;=&nbsp;{ &nbsp;&nbsp;name:&nbsp;&#39;Tom&#39;, &nbsp;&nbsp;getName:&nbsp;function()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;传统函数定义方式 &nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;self&nbsp;=&nbsp;this; &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;function()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(self.name);&nbsp;//&nbsp;输出&#39;Tom&#39; &nbsp;&nbsp;&nbsp;&nbsp;}; &nbsp;&nbsp;}, &nbsp;&nbsp;getNameArrow:&nbsp;function()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;箭头函数定义方式 &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(this.name);&nbsp;//&nbsp;输出&#39;Tom&#39; &nbsp;&nbsp;&nbsp;&nbsp;}; &nbsp;&nbsp;} }; const&nbsp;getName&nbsp;=&nbsp;obj.getName(); const&nbsp;getNameArrow&nbsp;=&nbsp;obj.getNameArrow(); getName(); getNameArrow();</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">箭头函数不绑定arguments对象,但可以使用剩余参数语法来获取传入的所有参数。例如:</p><pre class="brush:as3;toolbar:false">function&nbsp;test()&nbsp;{ &nbsp;&nbsp;console.log(arguments);&nbsp;//&nbsp;输出[1,&nbsp;2,&nbsp;3] } test(1,&nbsp;2,&nbsp;3); const&nbsp;testArrow&nbsp;=&nbsp;(...args)&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;console.log(args);&nbsp;//&nbsp;输出[1,&nbsp;2,&nbsp;3] }; testArrow(1,&nbsp;2,&nbsp;3);</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">箭头函数在以下场景中应用广泛:</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">用于回调函数,例如数组的map、reduce、filter等方法。</p><pre class="brush:as3;toolbar:false">const&nbsp;numbers&nbsp;=&nbsp;[1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5]; const&nbsp;doubled&nbsp;=&nbsp;numbers.map(x&nbsp;=&gt;&nbsp;x&nbsp;*&nbsp;2); console.log(doubled);&nbsp;//&nbsp;输出[2,&nbsp;4,&nbsp;6,&nbsp;8,&nbsp;10]</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">用于简化代码,例如事件监听器、定时器等。</p><pre class="brush:as3;toolbar:false">//&nbsp;传统函数定义方式 setTimeout(function()&nbsp;{ &nbsp;&nbsp;console.log(&#39;Hello,&nbsp;world!&#39;); },&nbsp;1000); //&nbsp;箭头函数定义方式 setTimeout(()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;console.log(&#39;Hello,&nbsp;world!&#39;); },&nbsp;1000);</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">用于处理this指向问题,例如在React中使用箭头函数定义组件方法。</p><pre class="brush:as3;toolbar:false">class&nbsp;App&nbsp;extends&nbsp;React.Component&nbsp;{ &nbsp;&nbsp;handleClick&nbsp;=&nbsp;()&nbsp;=&gt;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log(&#39;Button&nbsp;clicked!&#39;); &nbsp;&nbsp;} &nbsp;&nbsp;render()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;&lt;button&nbsp;onClick={this.handleClick}&gt;Click&nbsp;me!&lt;/button&gt;; &nbsp;&nbsp;} }</pre><p class="p1" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; white-space: normal;">综上所述,箭头函数是一种更加简洁、易于使用的函数定义方式,可以大大提高代码的可读性和可维护性。</p><p class="p2" style="margin-top: 0px; margin-bottom: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 15px; line-height: normal; font-family: &quot;Helvetica Neue&quot;; min-height: 17px; white-space: normal;"><br/></p>