<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eric Chou on Medium]]></title>
        <description><![CDATA[Stories by Eric Chou on Medium]]></description>
        <link>https://medium.com/@dean34520?source=rss-70d80dcc16c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BIjoGIsfLZIp2C_ZFjoGOQ.jpeg</url>
            <title>Stories by Eric Chou on Medium</title>
            <link>https://medium.com/@dean34520?source=rss-70d80dcc16c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:10:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dean34520/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[理解 JavaScript中的arguments 與 parameters]]></title>
            <link>https://dean34520.medium.com/%E7%90%86%E8%A7%A3-javascript%E4%B8%AD%E7%9A%84arguments-%E8%88%87-parameters-5028336976f6?source=rss-70d80dcc16c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/5028336976f6</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Eric Chou]]></dc:creator>
            <pubDate>Sun, 21 Apr 2019 13:39:54 GMT</pubDate>
            <atom:updated>2019-06-01T12:09:50.303Z</atom:updated>
            <content:encoded><![CDATA[<h3>[JavaScript] 理解 JS中的arguments 與 parameters</h3><p>在理解arguments之前，得先理解何謂參數，參數為要帶入函式中的變數，也就是我們在執行函式時可以任意帶入的值，下面例子中，”fruit”, “vegetable”就是所謂的參數。</p><pre>function eatFood(fruit, vegetable) {<br>  console.log(fruit)<br>  console.log(vegetable)<br>}</pre><p>在JavaScript中，一但宣告好這樣的函式後，可以不帶任何參數就去執行該函式，在程式的執行上不會有錯誤</p><pre>eatFood();  //執行eatFunction這個函式</pre><p>執行後的結果會是回傳兩個 undefined</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*tsTkOyPmyDtpUatpQO5eXQ.png" /></figure><p>為何是undefined?? 因為JavaScript中Hoisting中特性的關係，當function在執行時，便會在記憶體中先替變數建立好位置，並賦予undefined的值。</p><p>然而，若在執行函式時只帶入一個參數值的話，會怎樣呢？在JavaScript中既使參數值有缺，仍然可以正常運作</p><pre>eatFood(&#39;apple&#39;); 只傳入一個參數</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*sni21wlRF3loRq6a7UUzZQ.png" /></figure><p>然而，又由此可得知JavaScript在讀取參數值時，是由左至右的</p><h4>替參數建立預設值</h4><p>有時我們為了避免在執行函式時沒傳參數導致出現undefined的現象，會希望給定預設值，在ES6的語法中，可以直接在宣告function時就給定預設值</p><pre>function eatFood(fruit = &#39;apple&#39;, vegetable = &#39;cabbage&#39;) {<br>  console.log(fruit)<br>  console.log(vegetable)<br>}</pre><pre>//透過&quot;=&quot;來替參數設定預設值</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*0SuGDuPPPF8e34Ucz_-Lvg.png" /></figure><p>但因為版本支援度的關係，並非所有瀏覽器都支援，以往大部分給定預設值的寫法為以下方式</p><pre>function eatFood(fruit, vegetable) {<br>  fruit = fruit || &#39;apple&#39;<br>  vegetable = vegetable || &#39;cabbage&#39;<br>  console.log(fruit)<br>  console.log(vegetable)<br>}</pre><h4>arguments</h4><p>arguments是一個對應傳入函式之引數的類陣列（Array-like）物件。簡單來說也就是parameters的集合的概念。以上面的例子來說，arguments就是包含了fruit跟vegetable的一個類陣列物件。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*7l43os0dT8TWB0KZ9cO10w.png" /></figure><p>它是類陣列，不是真的陣列，雖然可以用arguments.length來取得裡面參數的數量以及可以直接使用arguments[index]來取得或修改特定位置的參數，但它並不能使用陣列的操作方法。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5028336976f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue系列文 —  將Vue檔案部署至Github]]></title>
            <link>https://dean34520.medium.com/vue%E7%B3%BB%E5%88%97%E6%96%87-%E5%B0%87vue%E6%AA%94%E6%A1%88%E9%83%A8%E7%BD%B2%E8%87%B3github-334951cadede?source=rss-70d80dcc16c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/334951cadede</guid>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Eric Chou]]></dc:creator>
            <pubDate>Wed, 13 Feb 2019 18:10:06 GMT</pubDate>
            <atom:updated>2021-01-03T12:29:14.191Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Vue] 將Vue專案部署至Github Pages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*wqYF-8Dmh7LhtLkKfERc3Q.png" /></figure><ol><li>先至Github建立與本地專案名稱相同的repository，在此以eric-project為例</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*Vg7ggUEh6FagnKaYZpfNIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t28lWZh53A2pL2QV-PUaMA.png" /></figure><p>2. 接著到專案資料夾中新增vue.config.js (Vue CLI 3 需要自行新增)，設定publicPath，當env為production時變更為eric-project，因為屆時Github Pages部署完成後的網址為<a href="https://chou0728.github.io/flexible-form/">https://chou0728.github.io/eric-project/</a>，因此根目錄為eric-project</p><pre>//vue.config.js</pre><pre>module.exports = {<br>  publicPath: process.env.NODE_ENV === &#39;production&#39;<br>    ? &#39;/eric-project/&#39;<br>    : &#39;/&#39;<br>}</pre><p>3. 將本地專案推送至雲端</p><pre>git init</pre><pre>git remote add origin <a href="https://github.com/chou0728/flexible-form.git">https://github.com/chou0728/eric-project.git</a></pre><pre>git add .</pre><pre>git commit -m &quot;Initial commit&quot;</pre><pre>git push -u origin master</pre><p>4. 在專案目錄下新增deploy.sh，Vue CLI 官方推薦用法，這是屬於 shell script (程式化腳本)，在執行該腳本也時會自動幫你執行裡面的指令，當然，若偏好自行輸入指令也可以不用使用</p><pre>//deploy.sh</pre><pre>#!/usr/bin/env sh</pre><pre># 當發生錯誤時終止腳本運行<br>set -e</pre><pre># 打包<br>npm run build</pre><pre># 移動至到打包後的dist目錄 <br>cd dist</pre><pre>git init //因為dist資料夾預設是被ignore的，因此在進入dist資料夾後初始化git<br>git add -A<br>git commit -m &#39;deploy&#39;</pre><pre># 部署到 https://github.com/chou0728/eric-project.git 分支為 gh-pages<br>git push -f https://github.com/chou0728/eric-project.git master:gh-pages</pre><pre>//將dist資料夾中的內容推送至遠端eric-project的gh-pages分支中，並強制無條件將舊有的內容取代成目前的內容（指令 git push -f)</pre><pre>cd -</pre><p>分支名稱會叫gh-pages是因為Github在部署時只允許三種來源(master, gh-pages, master/docs)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqCJWdhOC24Juu-aWQdd0A.png" /></figure><p>更多參考:</p><ul><li><a href="https://cli.vuejs.org/zh/guide/deployment.html#github-pages">部署 | Vue CLI 3</a></li><li><a href="https://gitbook.tw/chapters/github/using-force-push.html">【狀況題】聽說 git push -f 這個指令很可怕，什麼情況可以用它呢？ - 為你自己學 Git | 高見龍</a></li></ul><p>4. 執行腳本</p><pre>sh ./deploy.sh</pre><p>5. 執行完後，至Github頁面中會看到該專案多了一個branch叫做gh-pages</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8bm7vCe1PlouCZMeMQWDBA.png" /></figure><p>切換gh-pages分支後會看到裡面的內容跟本地中專案的dist資料夾內一樣</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_EsNfV3lhXdY4krSGZmVA.png" /><figcaption>標準的靜態網頁部署結構</figcaption></figure><p>6. 進入settings頁面，在GitHub Pages的設定區中，將Source改為gh-pages，並按下儲存，接著靜待幾分鐘後，點選上方提供的連結就可以看見部署後的靜態網頁了!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qMvhmUsfZgtnYrlmvUJ6MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*dM_ZT-70vXPIXw7Pw9zNdQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=334951cadede" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>