<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tri Nguyen</title>
    <description>The latest articles on DEV Community by Tri Nguyen (@trilemaestro92).</description>
    <link>https://dev.to/trilemaestro92</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F100787%2F960546a8-01bf-4bd0-aeff-8ef04072b2b8.jpeg</url>
      <title>DEV Community: Tri Nguyen</title>
      <link>https://dev.to/trilemaestro92</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trilemaestro92"/>
    <language>en</language>
    <item>
      <title>Understanding Linked List  </title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Thu, 07 Mar 2019 19:13:48 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/understanding-linked-list---4hbp</link>
      <guid>https://dev.to/trilemaestro92/understanding-linked-list---4hbp</guid>
      <description>&lt;p&gt;Greeting fellow coder. &lt;/p&gt;

&lt;p&gt;On this installment I will break down Linked List data structure...you will learn about the fundamentals, how they work, a variation called a "doubly linked list" (I didn't make that up), and ask the question... are they easy to learn and should you? spoiler...you should. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is A Linked List ?
&lt;/h2&gt;

&lt;p&gt;Linked List is a data structure consisting of a group of vertices (nodes) which together represent a sequence. Each vertex is composed of a data and a reference (link) to the next vertex in the sequence. In simpler terms, it is a flexible data structure that can store many nodes, and it does this by having each nodes point to the next node in the list.&lt;/p&gt;

&lt;p&gt;Linked List and its variations are used as underlying data structure to implement List, Stack, Queue, and ADTs(Abstract Data Types). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6ypkrhzggf3gum62yo83.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6ypkrhzggf3gum62yo83.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;breakdown:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;This particular linked list there is 7 nodes, and in each node there is a specific variable in this case they are numbers [22,2,77,6,43,76,89]&lt;/li&gt;
&lt;li&gt;The arrows for each nodes connecting one to another, these arrow are called pointers.&lt;/li&gt;
&lt;li&gt;The "head" label indicates when the linked list begin and the 'tail' label indicates when it ends.&lt;/li&gt;
&lt;li&gt;If you are looking at the tail node and wondering "hey isn't every node in a linked list suppose to have a pointer that points to the next node". You are 100% right, as a matter of fact the last node does have a next pointer value and it is 0 or null, which indicate you have reach the end of the list.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How do you use it?
&lt;/h2&gt;

&lt;p&gt;Since Linked List is such a fundamental and simple linear data structure. It has a range of potential applications as a list ADT(Abstract Data Type) e.g. student list, event list, appointment list, etc.&lt;/p&gt;

&lt;p&gt;As stated earlier Linked List is also being used as an underlying structure to create other more complex structure such as Queues and Stacks.&lt;/p&gt;

&lt;p&gt;Furthermore because linked list can be easily be reorder, split, trimmed, reverse, and so on. They can be pretty useful for algorithm like sorting.&lt;/p&gt;

&lt;p&gt;Lets try to &lt;strong&gt;search&lt;/strong&gt; a value of &lt;em&gt;43&lt;/em&gt; from the linked list example above&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fq5zax1vevojv3hhzkgm7.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fq5zax1vevojv3hhzkgm7.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;breakdown:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Searching through a linked list is fairly simple, the algorithm will check first at the head node if the value is 43. If no, it will continue to the next node by the way of the pointer and so on.&lt;/li&gt;
&lt;li&gt;You can predict it will go through 4 node until it reaches the node with the value 43. If we were to search for a value that is not on the linked list it will traverse through the whole list and eventually return null.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Lets try to &lt;strong&gt;insert&lt;/strong&gt; a value of &lt;em&gt;14&lt;/em&gt; at index 3 in the linked list&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6ypkrhzggf3gum62yo83.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6ypkrhzggf3gum62yo83.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fivd0ds1u8wzcyyu19djw.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fivd0ds1u8wzcyyu19djw.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;breakdown:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Originally at index 3 was a node with the value of 6&lt;/li&gt;
&lt;li&gt;To insert the new node (value 14) the algorithm first traverse from the head to index 3 then add the node .&lt;/li&gt;
&lt;li&gt;By adding the new node we change the pointers of index 2 (value 77) to point to the new node (value 14). While the inserted node (value 14) pointer is now pointing at index node 4 (value 6)
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Time to &lt;strong&gt;delete&lt;/strong&gt; a node in the linked list. Lets remove the node in index 2 (value 77)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6ypkrhzggf3gum62yo83.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6ypkrhzggf3gum62yo83.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbk3u35i79hlvwiq0ao35.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbk3u35i79hlvwiq0ao35.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;breakdown:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It is a fairly simple process&lt;/li&gt;
&lt;li&gt;We traverse to the node in index 2 (value 77), and remove it from the list.&lt;/li&gt;
&lt;li&gt;By removing the new node we change the pointers of index 1 (value 2) to point to now the new node from index 3 (value 14)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In summary Linked List is very similar to arrays when it comes to searching, inserting, or removing something in a list. But the difference comes from the Big O notation and how long it takes for each data structure to execute.&lt;/p&gt;

&lt;p&gt;EXTRA ....EXTRA&lt;/p&gt;

&lt;p&gt;Lets talk about a "doubly linked list". Since all of the previous example above are consider singly linked list. Here are some basic information on doubly linked list.&lt;/p&gt;

&lt;p&gt;reference from: Geeksforgeeks&lt;/p&gt;

&lt;p&gt;A Doubly Linked List contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.geeksforgeeks.org%2Fwp-content%2Fuploads%2Fgq%2F2014%2F03%2FDLL1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.geeksforgeeks.org%2Fwp-content%2Fuploads%2Fgq%2F2014%2F03%2FDLL1.png" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;some advantages for a Doubly Linked List(DDL):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A DLL can be traversed in both forward and backward direction. &lt;/li&gt;
&lt;li&gt;You can remove a node more efficiently 
disadvantage &lt;/li&gt;
&lt;li&gt;Every node in a DDL require extra space for the previous pointer
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why do you need to know Linked List ?
&lt;/h2&gt;

&lt;p&gt;Linked List are similar to Arrays in terms of a linear data structure. But unlike Arrays where their size is fixed and we must know the upper limit size of elements in advance, unlike Linked List which are more dynamic. Another advantage is the ease of insertion/deletion, in a linked list you do not have to create room and shift a node when you insert/delete like in Arrays, you only need to change the pointers to a new element when inserting/ deleting a new node.  &lt;/p&gt;

&lt;p&gt;In terms of Big O notation, the average time to access and search is Θ(n) slower than arrays. Insert, and delete data is Θ(1) faster than arrays.&lt;/p&gt;

&lt;p&gt;hopefully this article was helpful.&lt;/p&gt;

&lt;p&gt;Thanks for reading me !&lt;/p&gt;

</description>
      <category>datastructure</category>
    </item>
    <item>
      <title>Understanding Binary Search Tree </title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Tue, 11 Dec 2018 21:21:20 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/understanding-binary-search-trees--227p</link>
      <guid>https://dev.to/trilemaestro92/understanding-binary-search-trees--227p</guid>
      <description>&lt;p&gt;Greeting fellow coder. &lt;/p&gt;

&lt;p&gt;On this installment I will break down the Binary tree data structure...you will learn about the fundamentals, how they work, how to traverse/ walk through a tree, and ask the question... are they OVERRATED? spoiler...they're not. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is A Binary Tree ?
&lt;/h2&gt;

&lt;p&gt;First, it is one of the many data structure used to efficiently map keys to values, for efficient search/retrieval, insertion, and/or removals.&lt;/p&gt;

&lt;p&gt;A binary tree in particular has ONE root, that root has 2 child nodes, those 2 child nodes has 2 child nodes each, and eventually reach the leaves which are the last nodes that doesn't have any child node. If that didn't make a lot of sense check out an example picture of a binary tree below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.stack.imgur.com%2Fx8d4D.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.stack.imgur.com%2Fx8d4D.png" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;8 is the root ( there should only be one root)&lt;/li&gt;
&lt;li&gt;4 is the left child node, and 12 is the right child node &lt;/li&gt;
&lt;li&gt;4 and 8 both has 2 child nodes, and so on.&lt;/li&gt;
&lt;li&gt;1,3,5,7,9,11,13,15 are all leaves.&lt;/li&gt;
&lt;li&gt;It is called a binary tree because every node can have no more than 2 child node. (it is possible to have one child node, that just means the other child node is NULL)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How do you use it?
&lt;/h2&gt;

&lt;p&gt;The binary tree above is also a perfect example of a &lt;strong&gt;Binary Search Tree&lt;/strong&gt;, which states every child node left of the root must be less than the root node, and every child node to the right of the root must be higher.&lt;/p&gt;

&lt;p&gt;This ordering property enable us to search through the tree quickly.&lt;br&gt;
lets take a look at another tree, and this time lets &lt;em&gt;search&lt;/em&gt; for the number 83 &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkq4t9bceurqg3pir8hzp.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkq4t9bceurqg3pir8hzp.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We see that the root(84) is greater than 83 therefore we can cut out all of the child nodes from the right. &lt;/li&gt;
&lt;li&gt;That leaves us to 54 the left child node of the root, from there we see that 83 is higher than 54 so we will go to its right child node 73.&lt;/li&gt;
&lt;li&gt;73 left child is null, but its right child is 83! the number we wanted to search.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now lets say we want to &lt;em&gt;insert&lt;/em&gt; the number 90. The steps would be similar to search.&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;90 is higher than the root so we will go to the right to 87.&lt;/li&gt;
&lt;li&gt;90 is still higher than 87 so we will go right of node 87 to 94.&lt;/li&gt;
&lt;li&gt;90 is less that 94 so we will go to the left, where it is null.&lt;/li&gt;
&lt;li&gt;Since it is null this is where we will insert 90. Check below for results&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycsap2xonuthof1yub4k.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycsap2xonuthof1yub4k.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Removing&lt;/em&gt; a node in a tree is a little more complex. Let me show you.&lt;/p&gt;

&lt;p&gt;Lets take a look at this new binary search tree. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb0wm2h2251ounujpdapo.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb0wm2h2251ounujpdapo.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets say I want to remove 13.&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Starting from the root(89) which 13 is less than, so we move to the left child node which is 13.&lt;/li&gt;
&lt;li&gt;From there the function will ask if 13 is a leaf, which it is not.&lt;/li&gt;
&lt;li&gt;So it will go to the right, at 34 and ask if 34 is a leaf which it's not.&lt;/li&gt;
&lt;li&gt;Since 13 is less than 34 we will now move to the left child node of 34, 21.&lt;/li&gt;
&lt;li&gt;It will ask if 21 is a leaf, which it's not. &lt;/li&gt;
&lt;li&gt;Since 13 is less than 21, we will move to the left child node again at 20.&lt;/li&gt;
&lt;li&gt;Again at 20, we know it is not a leaf so we will move to the left child node to 14&lt;/li&gt;
&lt;li&gt;At 14 they will ask it if this node is a leaf, the answer is yes.&lt;/li&gt;
&lt;li&gt;Now the function will replace 13 with its "successor" 14. Results below&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1qn0r7kgdvcrzrssxojy.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1qn0r7kgdvcrzrssxojy.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lets Traverse!
&lt;/h2&gt;

&lt;p&gt;We just went through how to search, insert, and remove nodes from a binary tree. Lets now see how we can traverse one.&lt;/p&gt;

&lt;p&gt;There are 3 methods to traverse through a binary tree:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Inorder&lt;/strong&gt;&lt;br&gt;
In simple term we will go from left node, to root, than to right node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preorder&lt;/strong&gt;&lt;br&gt;
In simple term we will go from root, to left node, than to right node.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Postorder&lt;/strong&gt;&lt;br&gt;
In simple term we will go from left node, to right node, than root.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;*Typically Inorder traversal is most common because it allows the nodes to be printed in order. *&lt;/p&gt;

&lt;p&gt;lets take a look at this tree for example:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5gjr8lhomzvl0j9ukyd0.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5gjr8lhomzvl0j9ukyd0.JPG" alt="Alt text of image"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The Inorder traversal steps are:&lt;/p&gt;

&lt;p&gt;A. start from the root(75) and move toward the left node 3, then we can ask does 3 have a child left node? since 3 doesn't have a child left node. We will log 3 and move on to its right child node 7.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3)&lt;/strong&gt;&lt;br&gt;
B. Does 7 have a child left node? No, we will now log 7, and move on to it's right child node 24.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7)&lt;/strong&gt;&lt;br&gt;
C. Does 24 have a left child node? Yes, it is number 8. Now we ask if 8 have a left child node ? No, we will log 8.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8)&lt;/strong&gt;&lt;br&gt;
D. We will move back to 24 and log 24, because its child node 8 have already been logged, then move on to it's right child node 59.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8,24)&lt;/strong&gt;&lt;br&gt;
E. Does 59 have a left child node? No, so we will now log 59. Then traverse back to the root. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8,24,59)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;F. Because we've register all of the left child nodes of the root. We can now log 75. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8,24,59,75)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;G. Now we move on to the right of the root node to 95. And ask does it have a left child node? Yes, now to move to 91. Does 91 have a left child node? No, we can now log 91.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8,24,59,75,91)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;H. Because we've register all of the left child nodes of 95. We can now log 95. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8,24,59,75,91,95)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I. Then we can move on to 95 right child node 99. And ask, does 99 have a left child node? No, we can now log 99.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3,7,8,24,59,75,91,95, 99)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By using Inorder traversal through this Binary Tree, you can see it the nodes are printed in order. I will not go over Preorder or Postorder on this article but you can check out these easy to understand videos from Michael Sambol below using those 2 methods.&lt;/p&gt;

&lt;p&gt;Preorder: &lt;a href="https://youtu.be/1WxLM2hwL-U" rel="noopener noreferrer"&gt;https://youtu.be/1WxLM2hwL-U&lt;/a&gt;&lt;br&gt;
Postorder: &lt;a href="https://www.youtube.com/watch?v=4zVdfkpcT6U" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=4zVdfkpcT6U&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why do you need to know Binary Search Tree ?&lt;/p&gt;

&lt;p&gt;Binary search trees are collections that can efficiently maintain a dynamically changing data set in sorted order. Having a sorted array is useful for many tasks because it enables binary search to be used, to efficiently locate elements. &lt;/p&gt;

&lt;p&gt;In terms of Big O notation, the average time to search, insert, and delete data is Θ(log(n)).&lt;/p&gt;

&lt;p&gt;Who knows, you might be ask about binary search tree and how to traverse on in a interview.&lt;/p&gt;

&lt;p&gt;hopefully this article was helpful.&lt;/p&gt;

&lt;p&gt;Thanks for reading me !&lt;/p&gt;

</description>
      <category>datastructure</category>
    </item>
    <item>
      <title>Understanding Hash Table</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Tue, 27 Nov 2018 19:15:22 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/understanding-hash-table-n0b</link>
      <guid>https://dev.to/trilemaestro92/understanding-hash-table-n0b</guid>
      <description>

&lt;p&gt;Greeting fellow coder. &lt;br&gt;
Thank you for checking out my blog on breaking down Hash table. I will go over what it is, how to use it, and why you need to know this data-structure.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is &lt;em&gt;Hash Table&lt;/em&gt;?
&lt;/h1&gt;

&lt;p&gt;A hash table, is a data structure that uses a hash function to efficiently map keys to values, for efficient search/retrieval, insertion, and/or removals.&lt;/p&gt;

&lt;p&gt;Hash table is one of many data structure in computer science, for which their purpose is to essentially organize data, using a variety of management and storage format that enables us to  efficiently access and modify them.&lt;/p&gt;

&lt;p&gt;There are many other data structures like array, linked list, binary tree, etc.&lt;/p&gt;

&lt;p&gt;For this article I will focus on Hash Table, which is widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.&lt;/p&gt;

&lt;h1&gt;
  
  
  How do you use it ?
&lt;/h1&gt;

&lt;p&gt;Like any data structure, hash table is use to help solve data problems.&lt;/p&gt;

&lt;p&gt;Basically how efficient in time and space can you....&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;searching for an item&lt;/li&gt;
&lt;li&gt;insert an item&lt;/li&gt;
&lt;li&gt;delete an item&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The way a Hash table work is using &lt;strong&gt;Key =&amp;gt; value lookup&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  A.) You take &lt;strong&gt;input keys&lt;/strong&gt; run it through a &lt;strong&gt;hash function&lt;/strong&gt; where it will map those input keys into numbers which corresponds to number of indexes in an array.
&lt;/h3&gt;

&lt;p&gt;Lets say I have a list of names Michael, Bob, Jack, Becky. (these are my input keys) &lt;/p&gt;

&lt;h3&gt;
  
  
  B.) Run these inputs through a hash function.
&lt;/h3&gt;

&lt;p&gt;There are many ways you can code a hash function, but essentially the hash function should take in a input string (the names we listed) converts them into an integer, and then remaps that integer into an index in an arrays. &lt;/p&gt;

&lt;h3&gt;
  
  
  C.)  Boom we have associative values. Where we can now search, insert, and delete our data by using the Array index.
&lt;/h3&gt;

&lt;p&gt;note: The array that stores the data from the hash table will likely always be much smaller than all of the available potential hash code or key inputs.&lt;/p&gt;

&lt;h3&gt;
  
  
  D.) Example
&lt;/h3&gt;

&lt;p&gt;So lets picture we ran those names listed earlier into a hash function that holds the a max index of 7. &lt;/p&gt;

&lt;p&gt;[undefined, [Bob], undefined, undefined,[Becky], [[Michael], [Jack]], undefined,]&lt;/p&gt;

&lt;p&gt;So you can see there is 7 index in the array and all of those names have been map to a particular index.&lt;/p&gt;

&lt;p&gt;We can now search for a particular name, like Bob is at array[1] Becky is at [4] so on and so forth.&lt;/p&gt;

&lt;p&gt;*but what about array [5] which holds Michael and Jack.....well what a perfect segway into my- &lt;/p&gt;

&lt;p&gt;"last but not least" note: because of a finite index, this opens the door for "collision" which is when 2 or more hash code is map in the same index.  &lt;/p&gt;

&lt;p&gt;There are different ways to resolve a collision, a very common way is by storing them in a linked list rather than just the strings. Just think of it as assigning an id to each name then storing it on a hash table. &lt;/p&gt;

&lt;p&gt;So when looping through an index with multiple keys you are able to reference the specific name you want with their linked id.  &lt;/p&gt;

&lt;p&gt;That's about the basics of how a hash table operates. If you wish to learn more about hash tables the website below &lt;strong&gt;VisuAlgo&lt;/strong&gt; does a great job in presenting hash tables and other data structure in easy to understand slides and interactive activities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://visualgo.net/en/hashtable?slide=1"&gt;https://visualgo.net/en/hashtable?slide=1&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Why do you need to know hash table ?
&lt;/h1&gt;

&lt;p&gt;To do well in tech interview of course....&lt;/p&gt;

&lt;p&gt;Technically yes, but also remember data structures like hash table are methods to efficiently search, insert, and delete data. And hash table is one of the more popular methods use because of how efficient they are.&lt;/p&gt;

&lt;p&gt;In terms of Big O notation, the average time to search, insert, and delete data is O(1) which is pretty fast compare to all of the other data structure methods.   &lt;/p&gt;

&lt;p&gt;hopefully this article was helpful.&lt;/p&gt;

&lt;p&gt;Thanks for reading me !&lt;/p&gt;


</description>
      <category>datastructure</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>3 coding habits to unblock yourself (Part 3)</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Sun, 11 Nov 2018 21:26:42 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-3-1e7h</link>
      <guid>https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-3-1e7h</guid>
      <description>&lt;p&gt;Hello fellow coders.&lt;br&gt;
Here is the inevitable part 3 of some good habits to unblock yourself. If you missed the 1st and 2nd part you can check it out right here: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;part 1&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg"&gt;https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;part 2&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-2-4nge"&gt;https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-2-4nge&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Shall we begin.....&lt;/p&gt;

&lt;h1&gt;
  
  
  B-B-Break Points!
&lt;/h1&gt;

&lt;p&gt;What are break points you ask? &lt;/p&gt;

&lt;p&gt;"      It is a place in your code that can be pause/ stop, which allows you to examine your variable when your code is running .  "&lt;/p&gt;

&lt;p&gt;Here's a example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0zH6Prrk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wzftrp9hm9c9k6pfh3k0.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0zH6Prrk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wzftrp9hm9c9k6pfh3k0.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this "blast from the past" example, the FizzBuzz challenge, I decided to add a &lt;strong&gt;debugger&lt;/strong&gt; keyword at line 7 to pause the loop right before it finds a number divisible by 3. &lt;/p&gt;

&lt;p&gt;So instead of looping through the length of 100 for the challenge, it will start running the loop through the number 1....2.... then pause in the opened browser at 3 due to the break point that I added. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g0fPEv8Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kiouhr4medsf1ms209ao.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g0fPEv8Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kiouhr4medsf1ms209ao.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I hadn't added a &lt;strong&gt;debugger&lt;/strong&gt; keyword, then when the loop reaches the number 3 it should activate the if statement at line 6 which would then console.log "Fiz" and continue looping through the rest of the numbers &lt;/p&gt;

&lt;p&gt;So... you see, the &lt;strong&gt;debugger&lt;/strong&gt; keyword is a powerful tool devise by god to FREEZE TIME AND SPACE!&lt;/p&gt;

&lt;p&gt;or a really helpful Chrome dev tool. Which ever way you see it...  &lt;/p&gt;

&lt;p&gt;But jokes aside, the more I continue to develop and grow in web development, coding in parts and pieces then testing them have increase my efficiency. And having break points and using &lt;strong&gt;debugger&lt;/strong&gt; have made my life much easier.&lt;/p&gt;

&lt;p&gt;I strongly recommend checking out this video from the people of "Google Chrome Dev" to learn additional cool features from their DevTools utilizing break point:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/H0XScE08hy8"&gt;
&lt;/iframe&gt;
 &lt;/p&gt;

&lt;p&gt;Well its been really fun writing the "how to unblock yourself" series but all good things must co-&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PART 3.5 COMING SOON!!!!!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>debugging</category>
      <category>unblock</category>
    </item>
    <item>
      <title>3 coding habits to unblock yourself (Part 2)</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Thu, 08 Nov 2018 22:26:05 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-2-4nge</link>
      <guid>https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-2-4nge</guid>
      <description>&lt;p&gt;Hello fellow coders.&lt;br&gt;
welcome back to part 2 of some good habits to unblock yourself. If you missed the 1st part you can check it out right here: &lt;br&gt;
&lt;a href="https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg"&gt;https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets get started!&lt;/p&gt;

&lt;h1&gt;
  
  
  ERROR REFERENCE
&lt;/h1&gt;

&lt;p&gt;In part one I talked about console log and how it can help beginners like me see the errors and where they're located. In this article I will discuss the habit of learning error messages. &lt;/p&gt;

&lt;p&gt;JavaScript coding in particular is prone to errors due to its complex nature. Errors occur where you least expect them and they are one of the main cause of JS developer's banging their head in confusion. &lt;/p&gt;

&lt;p&gt;But fear not, I believe if you can build a habit of learning or even familiarizing yourself with some common error of JavaScript, this habit can help you unblock a bug or issue more efficient. &lt;/p&gt;

&lt;p&gt;In JavaScript there are many errors you can run across like ReferenceError, SyntaxError, RangeError, and many more. They all have different definitions and solutions. Therefore I would encourage you to start noticing some of the error code you are receiving and do a little research on them. Who knows once you come across the same error code more than once you can even built a radar for those error while coding and condition yourself to not make the same mistake.  &lt;/p&gt;

&lt;p&gt;BTW you can check JavaScript error code all out here:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A few common JavaScript errors
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Common SyntaxError:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;If errors: The “==” operator performs a comparison while the “=” operator assigns a value, very easy to mix up.&lt;/li&gt;
&lt;li&gt;Mismatch brackets, case sensitive, overall spelling mistakes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Common TypeError :
&lt;/h3&gt;

&lt;p&gt;1.Using an Array method on non-Array object can cause an error to occurs, since you'll be calling a method on an undefined object. &lt;/p&gt;

&lt;p&gt;example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ibuj520vuabw5zhjl0p.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ibuj520vuabw5zhjl0p.JPG" alt="Alt text of image" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;map method can only be used for Array not object&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;2.Using &lt;strong&gt;null&lt;/strong&gt; or &lt;strong&gt;undefined&lt;/strong&gt; as an object. This is an error that occurs in browser when you read a property or call a method on a null or undefined object.&lt;/p&gt;

&lt;p&gt;Those are some of common errors I've experienced. I'm certain in time my error list will grow as my knowledge on how to fix them. &lt;/p&gt;

&lt;p&gt;Hope this article was helpful. Part 3 coming soon!&lt;/p&gt;

&lt;p&gt;Thanks for reading me!  &lt;/p&gt;

</description>
      <category>errormessage</category>
      <category>javascript</category>
      <category>unblock</category>
    </item>
    <item>
      <title>Understanding This Keyword</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Fri, 02 Nov 2018 02:55:52 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/understanding-this-keyword-go9</link>
      <guid>https://dev.to/trilemaestro92/understanding-this-keyword-go9</guid>
      <description>&lt;p&gt;Greeting fellow coder. &lt;br&gt;
Thank you for checking out my blog on breaking down &lt;em&gt;This&lt;/em&gt; keywords on JavaScript. I will go over what it is, how to use it, and some rules you need to know.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is &lt;em&gt;This&lt;/em&gt; ?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;This&lt;/strong&gt;, is a JavaScript keyword that refers to the object it belongs to. &lt;/p&gt;

&lt;p&gt;For the example looking below you can see the &lt;em&gt;This&lt;/em&gt; keyword was referenced in 2 different objects person1(line 5) and person2(line 12) in the "test" method. I basically want to see the value of &lt;em&gt;this&lt;/em&gt; by console logging it.&lt;/p&gt;

&lt;p&gt;To call the test function, I must refer to the object that owns the space. Hence the &lt;em&gt;person1.test() and person2.test()&lt;/em&gt;. This is one of the more important concept when using &lt;em&gt;this&lt;/em&gt;, because The value of this will be determined by the call-site. Thus triggering one of the rules called &lt;strong&gt;implicit binding&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x8SCNOtT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/808l7ihkl5fojp438dem.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x8SCNOtT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/808l7ihkl5fojp438dem.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implicit Binding rule
&lt;/h2&gt;

&lt;p&gt;When called like this: person1.test() the value of this inside test will be the person1 object or when called like this: person2.test() the value of this inside foo will be the person2 object.&lt;/p&gt;

&lt;p&gt;Lets see what happens&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zk2g6b4x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lnknw68v38ycck8bsna8.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zk2g6b4x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lnknw68v38ycck8bsna8.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the the console, you can see the 2 objects on display, which shows all of person1 &amp;amp; person2 properties name location and, the test method. In simpler terms, the &lt;em&gt;this&lt;/em&gt; keyword is basically replacing the object name person1 &amp;amp; person2 with &lt;em&gt;this&lt;/em&gt;. Thus on line 5 and 12 of my code I could of written console.log(person1) and it would have had the same result. And this works because on my call-site (line 16-17) I used implicit binding. &lt;/p&gt;

&lt;p&gt;(I will show what happens if you don't refer to the object that this belongs to next.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Default rule
&lt;/h2&gt;

&lt;p&gt;When I call a function(that uses &lt;em&gt;this&lt;/em&gt;) in a normal way or without using implicit binding. The value of this inside that object will be the global object (or undefined in strict mode) &lt;/p&gt;

&lt;p&gt;For example: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YSjRRkSv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8ylxndzh0iw33nh1ixwa.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YSjRRkSv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8ylxndzh0iw33nh1ixwa.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On line 16 I've just saved the test function of person1 onto &lt;strong&gt;test2&lt;/strong&gt; as an variable.&lt;br&gt;
Then on the next line I'm calling that variable &lt;strong&gt;test2&lt;/strong&gt; as a function. &lt;/p&gt;

&lt;p&gt;Lets see the outcome.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fqmPB0Dy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yb1mz6762ya6y9m97qjy.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fqmPB0Dy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yb1mz6762ya6y9m97qjy.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What you're seeing here is the global object. Because of the way we called the function which was a undecorated and standalone function (line 17), the value of &lt;em&gt;this&lt;/em&gt; became the global object, which was different to when we used implicit binding to call the function.&lt;/p&gt;

&lt;p&gt;To recap I've explain the 2 of the more simple, basic rule when using &lt;strong&gt;this&lt;/strong&gt; keyword (Default and Implicit binding). I will now expand more on how the arrow function and "new" keyword can affect the value of &lt;strong&gt;this&lt;/strong&gt;. &lt;/p&gt;

&lt;h1&gt;
  
  
  Arrow Function rule
&lt;/h1&gt;

&lt;p&gt;First, if you are unfamiliar with what an arrow function is here is a quick example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K12_GXHm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/d9ej7f7fzgmrf6hjuppv.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K12_GXHm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/d9ej7f7fzgmrf6hjuppv.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An arrow function is just another method to writing a function, it includes parameters, name, variable, functionality, etc. (for anyone who is A.D.D the console log is 12)&lt;/p&gt;

&lt;p&gt;Next, using the previous example above I am going to change the test function into arrow function for person2, while leaving person1 a normal function. Inside both test, I simply want to return a greeting that reference both objects name.   &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k4Mvuv5C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/n7lxy58dal7uzn0miuos.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k4Mvuv5C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/n7lxy58dal7uzn0miuos.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cbq279u0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/93zxce9ydslbn7iojhsi.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cbq279u0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/93zxce9ydslbn7iojhsi.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the console log result, person1 was able to successfully reference its object name, meanwhile person2 object name is undefined. &lt;/p&gt;

&lt;p&gt;This is where the &lt;strong&gt;arrow function&lt;/strong&gt; rule comes into play. Basically when ever you use an arrow function nothing is bind. Neither the argument neither &lt;em&gt;this&lt;/em&gt; keyword, they are all free. &lt;/p&gt;

&lt;p&gt;Therefore inside the person2 arrow function, when you write "this.name" &lt;em&gt;this&lt;/em&gt; is referring to the "test" function, so you are actually coding "test.name" which of course will be undefined.&lt;/p&gt;

&lt;p&gt;Meanwhile person1 you can see, when "test" method is a normal function, &lt;em&gt;this&lt;/em&gt; is bind to either the global object or the parent object. Which in this case is the object person1.&lt;/p&gt;

&lt;p&gt;Next, I will go over the &lt;strong&gt;new&lt;/strong&gt; keyword and how it can affect &lt;strong&gt;this&lt;/strong&gt; keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;new&lt;/em&gt; keyword rule
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;new&lt;/strong&gt; keyword is used to call any function. When you call a function using &lt;strong&gt;new&lt;/strong&gt; keyword it creates an empty object named "this", then automatically return this object.  &lt;/p&gt;

&lt;p&gt;Therefore you don’t need to use the return keyword to return &lt;em&gt;this&lt;/em&gt; from the function. &lt;/p&gt;

&lt;p&gt;Lets take a look at an example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CB7nS1p1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t7o1ryj30mcl3s7pm7ha.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CB7nS1p1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/t7o1ryj30mcl3s7pm7ha.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I made a function called "person". Inside the function I'm telling it to set 2 properties (name &amp;amp; location) and making it equal to my 2 parameters. (Notice I didn't use return on the function to get the value of &lt;em&gt;this&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;I will then call on the "person" function (line 7) using &lt;strong&gt;new&lt;/strong&gt; keyword. With the arguments of "Jennifer" and "Seattle". And then console logging person3.&lt;/p&gt;

&lt;p&gt;No problem at all! &lt;/p&gt;

&lt;p&gt;Lets see what happens...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ib9YRtYW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/n58umc9o6bgj6wgu6ssg.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ib9YRtYW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/n58umc9o6bgj6wgu6ssg.JPG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because of the &lt;strong&gt;new&lt;/strong&gt; keyword rules which again states 1.)  Any function can be called with &lt;strong&gt;new&lt;/strong&gt;  2.) It will then Returns the this object&lt;/p&gt;

&lt;p&gt;I was able to call on the person function and passed through the argument inside the function parameters.Then it return to me an object (where I specified the 2 properties to equal my 2 arguments)&lt;/p&gt;

&lt;p&gt;A good analogy would be, think of the &lt;strong&gt;new&lt;/strong&gt; keyword as an factory and it's using "person" function as a model, to churn out as many other functions using the the person model.    &lt;/p&gt;

&lt;p&gt;There you have it.&lt;/p&gt;

&lt;p&gt;We have reached the end of the article of me going over the fundamental of &lt;strong&gt;this&lt;/strong&gt; keyword to you guys, hopefully this article was helpful. &lt;/p&gt;

&lt;p&gt;Thanks for reading me !&lt;/p&gt;

</description>
    </item>
    <item>
      <title>3 coding habits to unblock yourself (Part 1)</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Tue, 02 Oct 2018 19:05:21 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg</link>
      <guid>https://dev.to/trilemaestro92/3-coding-habits-to-unblock-yourself-part-1-9lg</guid>
      <description>&lt;p&gt;What is up fellow coder. &lt;br&gt;
Thank you for checking out my thoughts on some good habits that helped me get passed many coding road block efficiently.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Quick Disclaimer: I'm currently 2 months into a coding boot-camp, but am confident this could help others like myself to unblock from a beginner perspective.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Lets get right into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  CONSOLE LOG !!
&lt;/h2&gt;

&lt;p&gt;You've probably been told by a professor or an instructor many times on how console logging is really important to figure out bugs and issues. But to be honest I was brushing off this approach early in my brief coding "career", only because I was more focused on learning functions, queries, and tons of coding concepts (you know the meat and potatoes). Which is of course important in their own rights. And perhaps, I could even say the route I took was the right route when one begins their coding journey.     &lt;/p&gt;

&lt;p&gt;(Big BUT Alert!) &lt;/p&gt;

&lt;p&gt;But, I am here to say once you do get comfortable with the syntax and concepts of any language, console log should be the next thing you need to master. Seriously I actually didn't realize this my self until recently. &lt;br&gt;
Actually, let me describe to you what my thought process in coding before understanding the magic of console log.&lt;/p&gt;

&lt;h1&gt;
  
  
  When facing a problem &lt;strong&gt;before&lt;/strong&gt; console log
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Google the problem. &lt;/li&gt;
&lt;li&gt;Look at past activities. &lt;/li&gt;
&lt;li&gt;Ask my friend Matt (a classmate who sits next to me).&lt;/li&gt;
&lt;li&gt;Start doubting my life choices. &lt;/li&gt;
&lt;li&gt;Carefully read through every line in my code for spelling errors :'(&lt;/li&gt;
&lt;li&gt;Ask my instructor for help.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  When facing a problem &lt;strong&gt;after&lt;/strong&gt; console log
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Run my code with a console log, receive a error message.&lt;/li&gt;
&lt;li&gt;Read the error message. &lt;/li&gt;
&lt;li&gt;Fix the code where the error message said it was located.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Of course it not as simple but that's basically the main idea. &lt;/p&gt;

&lt;p&gt;To my point, any new developer would prefer the latter. But like I stated earlier (at least for me), if I'm not comfortable with knowing the fundamentals and concepts of a language first, trying to console log everything would be less effective in my opinion. Since I wouldn't know what/where to console log.    &lt;/p&gt;

&lt;p&gt;Thus, with that being said once you do feel like you grasp the fundamentals and concepts, try to master the art of console log next it is one of the best ways to hurdle through any coding roadblock.  &lt;/p&gt;

&lt;p&gt;I hoped that was helpful &lt;/p&gt;

&lt;p&gt;(Part 2 coming soon) &lt;/p&gt;

</description>
      <category>habits</category>
      <category>unblock</category>
      <category>consolelog</category>
    </item>
    <item>
      <title>Understand basic REST Methods </title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Tue, 25 Sep 2018 19:41:14 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/understand-basic-rest-methods--2ka1</link>
      <guid>https://dev.to/trilemaestro92/understand-basic-rest-methods--2ka1</guid>
      <description>&lt;p&gt;What is up fellow coder.&lt;br&gt;&lt;br&gt;
Thank you for checking out my article on Understanding REST methods and its correlation with EXPRESS server. &lt;/p&gt;

&lt;p&gt;Lets get right into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is REST Method ?
&lt;/h2&gt;

&lt;p&gt;Well it stands for Representational State Transfer.......&lt;/p&gt;

&lt;p&gt;Ok, since this article is about REST methods associated with Express Router and Node.js. REST is the different HTTP routes that can define the relationship/interaction between the client/server for our applications. &lt;/p&gt;

&lt;p&gt;And these methods can be used to map out &lt;strong&gt;CRUD&lt;/strong&gt; (create, retrieve, update, delete) operations. An example of CRUD application can be Facebook, because you can create content, retrieve content, update content, and delete content. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Big Picture&lt;/strong&gt;: when building a CRUD application you will need your &lt;br&gt;
Web page(html,CSS, and JavaScript), a database to get and store data, and a Server to configure the application and create routes between clients and database. Essentially you can imagine using REST methods is used as a way for the server to respond to what the client wants to do and apply the changes to the database.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Lets Apply
&lt;/h2&gt;

&lt;p&gt;Lets take a look at some of the main REST methods and their correlation with a CRUD application. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;GET - this method retrieves information, a GET request can be made by a client or server to get information from a database. (The &lt;em&gt;retrieve&lt;/em&gt; part of CRUD) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;POST - this request is often used to create a new entity. Clients post new content, which in turn the content will either create new data or update data in the database. (the &lt;em&gt;create&lt;/em&gt; part of CRUD)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PUT - Store an entity at a URI. PUT can update an existing entity. A PUT request is idempotent, meaning clients can make that same call repeatedly while producing the same result. (the 'update' part of CRUD)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DELETE - Request that a resource be removed. If a client removes a content, the database will remove that content from the database. (the 'delete' part of CRUD)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>rest</category>
      <category>express</category>
    </item>
    <item>
      <title>How to Toggle between Images on Click</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Tue, 25 Sep 2018 17:57:42 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/how-to-toggle-between-images-on-click-ml4</link>
      <guid>https://dev.to/trilemaestro92/how-to-toggle-between-images-on-click-ml4</guid>
      <description>&lt;p&gt;What is up fellow coder. &lt;br&gt;
Thank you for checking out my article on learning how to toggle between images on click. &lt;/p&gt;

&lt;p&gt;Lets get right into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5fKX6EZU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0dcwyehim8sya3apq3nq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5fKX6EZU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0dcwyehim8sya3apq3nq.PNG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Here we have a simple HTML document with a stylesheet link to the icons I am using on the head. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the body I have the 2 icon/images I want to toggle. In this case it is a check box and a uncheck box. Both of the icons are wrapped inside a &lt;strong&gt;span&lt;/strong&gt; tag class name = 'tog'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And if you look closely in line 8. I made sure the &lt;em&gt;checked&lt;/em&gt; box style is hidden using &lt;strong&gt;display:none&lt;/strong&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Now lets look inside the Javascript
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kr_UBoSy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/sworwl9lc4tx4hrc6w0d.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kr_UBoSy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/sworwl9lc4tx4hrc6w0d.PNG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Along with the Javascript, I am also using some jQuery method.&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the selector I am selecting the &lt;strong&gt;span&lt;/strong&gt; tag class. Then on click it will run a &lt;strong&gt;function&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;function&lt;/strong&gt; is selecting an &lt;em&gt;i&lt;/em&gt; tag which is the tag for both the check and un-check icon.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lastly, I am using the &lt;strong&gt;toggle&lt;/strong&gt; function to toggle between the two icons.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;EZ PZ !&lt;/p&gt;

&lt;p&gt;You can test it out here!&lt;br&gt;
&lt;a href="https://codepen.io/anon/pen/qMzyyw"&gt;https://codepen.io/anon/pen/qMzyyw&lt;/a&gt;&lt;/p&gt;

</description>
      <category>toggle</category>
      <category>jquery</category>
    </item>
    <item>
      <title>How to add event listener to dynamically added elements</title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Tue, 18 Sep 2018 19:33:30 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/how-to-add-event-listener-to-dynamically-added-elements--1iea</link>
      <guid>https://dev.to/trilemaestro92/how-to-add-event-listener-to-dynamically-added-elements--1iea</guid>
      <description>&lt;p&gt;What is up fellow coder. &lt;br&gt;
Welcome to my second installment of "How to" guides &lt;br&gt;
Thank you for checking out my article on learning how to add event listener to dynamically added element. &lt;/p&gt;

&lt;p&gt;Lets get right into it!&lt;/p&gt;

&lt;h1&gt;
  
  
  First add a element
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ighj6frm39cjixdbr5c.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ighj6frm39cjixdbr5c.PNG" alt="Alt text of image" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpevkp8etswkzc91hvw7j.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpevkp8etswkzc91hvw7j.PNG" alt="Alt text of image" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The breakdown
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I have a simple HTML document that includes a &lt;strong&gt;button&lt;/strong&gt; named "click me" and also an empty &lt;strong&gt;div&lt;/strong&gt;. Both element have an id.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the JavaScript file, in line 8 I made a render function that should append a string to an element, which in this case will be on the empty &lt;strong&gt;div&lt;/strong&gt; from earlier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Therefore line 1-5 it's just me making a &lt;strong&gt;function&lt;/strong&gt; called "addButton" that uses render function to make a new &lt;strong&gt;button&lt;/strong&gt; called "new button". Line 15 is the event listener that adds a new button every time I click on "click me".&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we can add a button. How can we add an event listener to that new button ?&lt;/p&gt;

&lt;h2&gt;
  
  
  Let me show you DE WAY
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8ka6dcp87ejuwwzrgxos.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8ka6dcp87ejuwwzrgxos.PNG" alt="Alt text of image" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The breakdown
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The answer starts on line 16. First I create a event listener for the &lt;strong&gt;#content&lt;/strong&gt; which if you remember is the main selector id for the empty div on the html document . &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then for the &lt;strong&gt;on&lt;/strong&gt; function the &lt;em&gt;first parameter&lt;/em&gt; is action value "click", the &lt;em&gt;second parameter&lt;/em&gt; will be a child-selector name which in this case the class of the new button added(see line 3). The &lt;em&gt;third parameter&lt;/em&gt; is a callback value, in which I made a function that will turn the new button background yellow.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;EZ PZ!!&lt;/p&gt;

&lt;p&gt;As you can see I was able to add an event listener on my "new button", if when I click on the new button it will change its background to yellow. &lt;/p&gt;

&lt;h2&gt;
  
  
  Nice Gibberish...but what is the point???
&lt;/h2&gt;

&lt;p&gt;Well since you now know the basics on how to add an event listener to a dynamically added element. You don't need me to tell you of all the possibility you can use this function with or how commonly this is used. Just think any time you post something on Facebook, Twitter, or LinkedIn you are essential dynamically adding a element to a page. Thus if you can't add a event listener to them how are you able to comment, like, or react to those post.     &lt;/p&gt;

</description>
      <category>jquery</category>
      <category>guide</category>
      <category>eventlistener</category>
    </item>
    <item>
      <title>Understanding the basic of Module Pattern </title>
      <dc:creator>Tri Nguyen</dc:creator>
      <pubDate>Thu, 13 Sep 2018 17:08:13 +0000</pubDate>
      <link>https://dev.to/trilemaestro92/understanding-the-basic-of-module-pattern--4oab</link>
      <guid>https://dev.to/trilemaestro92/understanding-the-basic-of-module-pattern--4oab</guid>
      <description>&lt;p&gt;What is up! fellow coders.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Quick disclaimer: I'm a month into a coding bootcamp, but am confident this could help others like myself understand module pattern from a beginner perspective.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;So lets begin.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Module
&lt;/h2&gt;

&lt;p&gt;First, to understand The Module pattern(MP) you need to understand what is a module. &lt;/p&gt;

&lt;p&gt;Modules are an integral part of any large application's architecture and typically help in keeping the units of code for a project both cleanly separated and organized.&lt;/p&gt;

&lt;p&gt;In JavaScript there are several ways to implement a module like object literal notation, AMD modules, and CommonJS module to name a few. But in this article I will be focusing on The Module Pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ok...... can you show me an example?
&lt;/h2&gt;

&lt;p&gt;Yes. but first&lt;/p&gt;

&lt;p&gt;The Module pattern (MP) was originally defined as a way to provide both private and public environment for classes in software engineering.&lt;/p&gt;

&lt;p&gt;In JavaScript the MP further enhances on that notion. We're able to include both public/private methods and variables inside a single object, thus shielding particular parts from the global scope. With this pattern, only a public API is returned, keeping everything else within the closure private. This privacy pattern can sometimes utilize an immediately-invoked function expression (IIFE)  where an object is returned.&lt;/p&gt;

&lt;p&gt;Your take away from that should be "the module pattern is one of the methods that uses a module to keep certain codes, variables,functions, etc. inside a single object, so it doesn't pollute the global scope. Thus keeping our code clean and organize "&lt;/p&gt;

&lt;p&gt;Cool beans&lt;/p&gt;

&lt;p&gt;Lets take a look at an example of a module pattern and break it down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffxtoaqzvbbnqd25tthnd.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffxtoaqzvbbnqd25tthnd.PNG" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The breakdown
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I made a module using an IIFE and called it "myModule".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside the module I declared a variable &lt;strong&gt;myGreeting&lt;/strong&gt; ,an object called &lt;strong&gt;myObject&lt;/strong&gt; and 2 functions &lt;strong&gt;saySomething&lt;/strong&gt; and &lt;strong&gt;sayGreeting&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inside my function I can reference variables like &lt;strong&gt;myGreeting&lt;/strong&gt; in both the functions and even a property of an object the name and food from &lt;strong&gt;myObject&lt;/strong&gt;.   &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then you can see from line 18-22 I made a variable called public API in order to reference the 2 function inside my module and to return them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lastly because of the public API and my ability to return the function I can now call the 2 function on line 26 and 28.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Therefore, what makes &lt;em&gt;myModule&lt;/em&gt; a module pattern is how I was able to make everything inside private from the global scope. Thus the only way to return the function inside is by using the public API that reference them. &lt;/p&gt;

&lt;h2&gt;
  
  
  Nice Gibberish but what is the point ???
&lt;/h2&gt;

&lt;p&gt;Of course my example was very simple, but just imagine how important this method can be when dealing with a robust amount of code on a large project with multiple developers working on it. The module pattern can keep the global scope clean and organize and prevent duplicate variables from overriding each other.&lt;/p&gt;

</description>
      <category>modulepattern</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
