<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>JS &amp; TS on My Notes</title><link>https://harryho.github.io/coding/js-ts/</link><description>Recent content in JS &amp; TS on My Notes</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://harryho.github.io/coding/js-ts/index.xml" rel="self" type="application/rss+xml"/><item><title>JS &amp; ES Note - 1</title><link>https://harryho.github.io/coding/js-ts/js-note-1/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/js-ts/js-note-1/</guid><description>&lt;h2 id="the-most-unpredictable-keyword-and-feature"&gt;The most unpredictable keyword and feature&lt;a class="anchor" href="#the-most-unpredictable-keyword-and-feature"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You may already guessed what I am talking about. Yes, the&lt;strong&gt;this&lt;/strong&gt; keyword. It is not only a powerful feature, but also often misinterpreted keyword.&lt;/p&gt;
&lt;p&gt;In JavaScript, we also have this concept inside a Function constructor when it is invoked using the “new” keyword, however it is not the only rule and “this” can often refer to a different object from a different execution context.&lt;/p&gt;</description></item><item><title>JS &amp; ES Note - 2</title><link>https://harryho.github.io/coding/js-ts/js-note-2/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/js-ts/js-note-2/</guid><description>&lt;h2 id="the-equal-operator-doesnt-always-mean-equivalent"&gt;The equal operator doesn&amp;rsquo;t always mean equivalent&lt;a class="anchor" href="#the-equal-operator-doesnt-always-mean-equivalent"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote class='book-hint '&gt;
&lt;p&gt;Have you got confused by the equal or not equal expression in the JavaScript? I will say you are definitely not the only one. Even many senior developers come from back-end programming background, they all scratch the head to find out why the equal or not-equal expression doesn&amp;rsquo;t work as they expect. The truth is those expression are really different from other programming language.&lt;/p&gt;</description></item><item><title>JS &amp; ES Note - 3</title><link>https://harryho.github.io/coding/js-ts/js-note-3/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/js-ts/js-note-3/</guid><description>&lt;h3 id="the-var-statement"&gt;The &lt;strong&gt;var&lt;/strong&gt; statement&lt;a class="anchor" href="#the-var-statement"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;var declarations, wherever they occur, are processed before any code is executed. This is called hoisting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The scope of a variable declared with var is its current execution context, which is either the enclosing function or, for variables declared outside any function, global. If you re-declare a JavaScript variable, it will not lose its value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Assigning a value to an undeclared variable implicitly creates it as a &lt;strong&gt;global&lt;/strong&gt; variable (it becomes a property of the global object) when the assignment is executed.&lt;/p&gt;</description></item><item><title>JS &amp; ES snippet</title><link>https://harryho.github.io/coding/js-ts/js-note-99/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/js-ts/js-note-99/</guid><description>&lt;h3 id="setup-the-global-node-modules"&gt;Setup the global node modules&lt;a class="anchor" href="#setup-the-global-node-modules"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Add an environment variable to tell node where the global node module sits&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;# I use nvm to manage my node and node modules&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;export&lt;/span&gt; &lt;span style="color:#953800"&gt;NODE_PATH&lt;/span&gt;&lt;span style="color:#0550ae"&gt;=&lt;/span&gt;&lt;span style="color:#0a3069"&gt;${&lt;/span&gt;&lt;span style="color:#953800"&gt;HOME&lt;/span&gt;&lt;span style="color:#0a3069"&gt;}&lt;/span&gt;/.nvm/versions/node/&amp;lt;node_version&amp;gt;/lib/node_modules&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If you use npm by default, you may have permission problem to access the node modules. I suggest you to set a customized global node module folder under your home directory.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a new folder under your home directory&lt;/li&gt;
&lt;li&gt;Install npm to new global node module&lt;/li&gt;
&lt;li&gt;update environment variables in the profile&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#f7f7f7;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir &lt;span style="color:#953800"&gt;$HOME&lt;/span&gt;/.node_modules
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;npm config &lt;span style="color:#6639ba"&gt;set&lt;/span&gt; prefix &lt;span style="color:#953800"&gt;$HOME&lt;/span&gt;/.node_modules
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;npm install -g npm
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;echo&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;export NODE_MODULES=$HOME/.node_modules&amp;#39;&lt;/span&gt; &amp;gt;&amp;gt; &lt;span style="color:#953800"&gt;$HOME&lt;/span&gt;/.profile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;echo&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;export PATH=$PATH:$NODE_MODULES/bin&amp;#39;&lt;/span&gt; &amp;gt;&amp;gt; &lt;span style="color:#953800"&gt;$HOME&lt;/span&gt;/.profile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;source&lt;/span&gt; &lt;span style="color:#953800"&gt;$HOME&lt;/span&gt;/.profile&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="parsing-csv-file"&gt;Parsing CSV file&lt;a class="anchor" href="#parsing-csv-file"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id="parse-csv-file-with-fast-csv"&gt;Parse csv file with fast-csv&lt;a class="anchor" href="#parse-csv-file-with-fast-csv"&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Install package fast-csv globally&lt;/p&gt;</description></item><item><title>TS: Basic Types</title><link>https://harryho.github.io/coding/js-ts/ts-note-1/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://harryho.github.io/coding/js-ts/ts-note-1/</guid><description>&lt;h2 id="basic-types"&gt;Basic Types&lt;a class="anchor" href="#basic-types"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In TypeScript, the same types as you would expect in JavaScript are supported, with a convenient enumeration type thrown in to help things along.&lt;/p&gt;
&lt;h3 id="types-in-javascript"&gt;Types in JavaScript&lt;a class="anchor" href="#types-in-javascript"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Boolean - The most basic datatype is the simple true/false value, aka boolean value.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; let isDone: boolean = false;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Number - All numbers in TypeScript are floating point values.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; let decimal: number = 6;
 let hex: number = 0xf00d;
 let binary: number = 0b1010;
 let octal: number = 0o744;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;String - Another fundamental part of creating programs in JavaScript for webpages and servers alike is working with textual data. TypeScript also uses double quotes (&amp;quot;) or single quotes (&amp;rsquo;) to surround string data.&lt;/p&gt;</description></item></channel></rss>