<?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: Susan Wangari</title>
    <description>The latest articles on DEV Community by Susan Wangari (@wangari).</description>
    <link>https://dev.to/wangari</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F428264%2F78939325-46ca-468a-974f-ba33f0eb48eb.jpeg</url>
      <title>DEV Community: Susan Wangari</title>
      <link>https://dev.to/wangari</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wangari"/>
    <language>en</language>
    <item>
      <title>Deep Dive into Data Structures and Algorithms</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Wed, 29 Jun 2022 20:27:35 +0000</pubDate>
      <link>https://dev.to/wangari/deep-dive-into-data-structures-and-algorithms-21kb</link>
      <guid>https://dev.to/wangari/deep-dive-into-data-structures-and-algorithms-21kb</guid>
      <description>&lt;p&gt;One important thing to note is that for an algorithm to be considered effective, it should take the least time to execute and use the least amount of memory or space. There are different ways of calculating the performance of an algorithm:&lt;/p&gt;

&lt;h2&gt;
  
  
  Space complexity
&lt;/h2&gt;

&lt;p&gt;In simple terms, whenever a solution to a problem is written, some memory is required to complete it.This is the amount of space required by an algorithm in order to execute. The input determines the space needed for execution- a larger input size means more memory is required. &lt;/p&gt;

&lt;h3&gt;
  
  
  Components that require space
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Instruction space&lt;/strong&gt;. This is the space required to store the executable version of the program. It is fixed but varies depending on the number of lines of code in the program. It is used to store the compiled version of instructions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data space&lt;/strong&gt;. The space required to store all the constants and variables including temporary variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environment space&lt;/strong&gt;. The space required to store the environment information needed to resume the suspended function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculating Space Complexity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To calculate space complexity, it is important to know the value of memory used by different types of datatype variables for example; a &lt;em&gt;boolean, character and int8&lt;/em&gt; have 1 byte each while &lt;em&gt;float&lt;/em&gt; has 4 bytes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let d = a+b+c;
console.log(d);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Variables &lt;em&gt;a,b,c&lt;/em&gt; and &lt;em&gt;d&lt;/em&gt; are &lt;strong&gt;integer&lt;/strong&gt;  types hence they will take up 4 bytes each, so the total memory will be &lt;em&gt;(4(4) + 4)&lt;/em&gt; where the extra 4 bytes is for the console.log. This is an example of &lt;strong&gt;constant space complexity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An example of &lt;strong&gt;Linear Space Complexity&lt;/strong&gt; is illustrated below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum (a[],n) {
  let y= 0;
  for(let i=0; i&amp;lt;n; i++) {
   y = y + a[i];
 }
return y;
}
sum();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the space required is &lt;code&gt;4*n&lt;/code&gt; bytes for the array &lt;code&gt;a[]&lt;/code&gt; elements. 4 bytes is then required for &lt;code&gt;y,n,i&lt;/code&gt; and the return value. The total requirement is &lt;code&gt;&lt;br&gt;
(4n+12)&lt;/code&gt; which is increasing linearly with the increase of the input value &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Time complexity
&lt;/h2&gt;

&lt;p&gt;This is the total time required by a program to run until its completion. It is estimated by counting the number of elementary steps performed by an algorithm from start to finish execution.&lt;/p&gt;

&lt;p&gt;Time complexity is commonly expressed using the &lt;strong&gt;Big O Notation&lt;/strong&gt;. This is the asymptotic(pertaining values approached at infinity) notation that represents the time complexity. Since an algorithm's performance may change depending on the input, the complexity that is commonly used is &lt;strong&gt;Worst-case time complexity&lt;/strong&gt;. This is the maximum time taken for any input size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculating Time Complexity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are different types of time complexity.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Constant Time Complexity&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The running time does not change in relation to the input. It is denoted by &lt;strong&gt;O(1)&lt;/strong&gt; where O is Big O. This is the fastest time complexity. It is considered the best case scenario for an algorithm because no matter how big the input size is, it takes the same amount of time to execute.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example:Array look up&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr1 = [1,2,4,5];
arr1.index(2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Linear Time Complexity&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The running time is directly proportional to the input &lt;code&gt;N&lt;/code&gt;. Performance grows in direct proportion to the size of the input data set. It is denoted by &lt;strong&gt;O(n)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let arr2 = [10,20,30,40,50];
let printValue
for (let i = 0; i &amp;lt; arr2.length; i++) {
  let printValue += arr2[i] ;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The program has to loop through the array to print each element.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quadratic Time Complexity&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The running time is directly proportional to the square of the input &lt;code&gt;N&lt;/code&gt;. It is denoted by &lt;strong&gt;O(n*n) or O(n^2)&lt;/strong&gt;. This is used because the complexity completes both O(1) and O(n).  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let text = "";
for(let i = 0; i &amp;lt; N; i++) {
  for(let j = 0; j &amp;lt; N; j++) {
    text += `The number is ${i} + ${j};`
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Logarithmic Time Complexity&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The running time is proportional to the number of times &lt;code&gt;N&lt;/code&gt; can be divided by 2. The working area is divided by 2 with each iteration. It is denoted by &lt;strong&gt;O(log n)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function logTime(arr) {
  let numberOfLoops = 0
  for (let i = 1; i &amp;lt; arr.length; i *= 2) {
    numberOfLoops++
  }
  return numberOfLoops
}

let loop1 = logTime([1, 2, 3, 4]) // 2 loops
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the example above, every time the input length is doubled, the number of operations increases linearly by 1 which makes it half of the input length.&lt;/p&gt;

&lt;p&gt;Understanding time and space complexity is important for every developer because it helps one to choose the best case to use for execution and hence ensure that the algorithm is performing at its best state while using the least memory.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Data Structures and Algorithms</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Sat, 18 Jun 2022 13:04:46 +0000</pubDate>
      <link>https://dev.to/wangari/introduction-to-data-structures-and-algorithms-471e</link>
      <guid>https://dev.to/wangari/introduction-to-data-structures-and-algorithms-471e</guid>
      <description>&lt;p&gt;For some of us, especially those new to programming,hearing algorithms and data structures seems like a complex thing. Well, the good news is that this article will break it down in the simplest way possible.&lt;/p&gt;

&lt;p&gt;To elaborate on what &lt;strong&gt;data structures&lt;/strong&gt; are, they are containers for storing data to allow easy manipulation. Think of them as a way of organizing data so that one is able to operate. There are different types of data structures. One type is primitive data structures.These are inbuilt data structures such as &lt;em&gt;int,boolean, arrays, and objects&lt;/em&gt;. There are also abstract data structures are defined by a set of operations and values. They include &lt;em&gt;links, trees, graphs and stacks&lt;/em&gt;.  &lt;/p&gt;

&lt;p&gt;To define &lt;strong&gt;algorithms&lt;/strong&gt;, they are a set of instructions to help you perform an operation. An example of where one would apply algorithms is in &lt;em&gt;baking a cake. You prepare the ingredients and follow a step by step process to achieve a result.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;There are different properties that an algorithm possesses. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;They include having an &lt;strong&gt;input&lt;/strong&gt;. &lt;em&gt;In the cake example, the input is the ingredients used to bake the cake.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An algorithm must also have an &lt;strong&gt;output&lt;/strong&gt;. &lt;em&gt;In our example, the output is the baked cake&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An algorithm must have every step clearly defined. &lt;em&gt;For example, define all the steps involved in baking the cake&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every algorithm should have a defined number of steps from beginning to the end. &lt;em&gt;At some point, we have to finish baking the cake.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For an algorithm to be considered effective, every step should produce a correct output. &lt;em&gt;For example, we cannot follow the steps of baking a cake then produce pizza, it has to be cake.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;View data structures as applicable in every area of our lives and as being used to enhance our effectiveness in performing tasks.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Short-circuiting in JavaScript</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Fri, 15 Apr 2022 17:36:26 +0000</pubDate>
      <link>https://dev.to/wangari/short-circuiting-in-javascript-4o2a</link>
      <guid>https://dev.to/wangari/short-circuiting-in-javascript-4o2a</guid>
      <description>&lt;p&gt;Ever heard of short-circuiting in JavaScript? It's not something strange, believe me. You might have even interacted with some parts of it at one point. Well, short-circuiting is a way of simplifying conditionals while making code more readable. In most cases, short-circuiting is utilized in place of if-else expressions. It can be used for both single and multiple if-else statements.&lt;/p&gt;

&lt;p&gt;There are various operators used in short-circuiting. They include OR and AND. OR which is denoted by ||  is used to test a single condition. If one condition is right, then the code executes successfully. Check out the example below;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
const response = "Foo";&lt;br&gt;
const username = response || "guest";&lt;br&gt;
console.log(username);&lt;br&gt;
&lt;/code&gt; &lt;br&gt;
The code above checks if there is a response. If there is one, it returns the response. If not, it returns &lt;em&gt;guest&lt;/em&gt; as the username.&lt;/p&gt;

&lt;p&gt;AND which is denoted by &amp;amp;&amp;amp; is used to test for multiple conditions. For the code to run, all of the requirements must be met. Look at the following illustration;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
const response = "Foo";&lt;br&gt;
const isEmailVerified = true;&lt;br&gt;
const username = isEmailVerified &amp;amp;&amp;amp; response ;&lt;br&gt;
console.log(username);&lt;br&gt;
&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;This code evaluates when there is a response and the email is verified.&lt;br&gt;
Both AND and OR operators can be used in one operation. For example;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
const response = "Foo";&lt;br&gt;
const isEmailVerified = true;&lt;br&gt;
const username = isEmailVerified &amp;amp;&amp;amp; response || "guest";&lt;br&gt;
console.log(username);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
In such a scenario, the AND is executed before the OR. &lt;br&gt;
There is a technique to 'override' this and allow the OR to run first. This is accomplished by the use of parenthesis. Which operators are run first are specified by parentheses. Here is an example;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
const response = "Foo";&lt;br&gt;
const isEmailVerified = true;&lt;br&gt;
const username = isEmailVerified &amp;amp;&amp;amp; (response || "guest");&lt;br&gt;
console.log(username);&lt;br&gt;
&lt;/code&gt; &lt;br&gt;
In this case, the OR is executed before the AND operator.&lt;/p&gt;

&lt;p&gt;In conclusion, short-circuiting should not be used as a way to shorten code but as a way to make code more readable.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Leading a Community</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Wed, 18 Aug 2021 14:09:00 +0000</pubDate>
      <link>https://dev.to/wangari/leading-a-community-e0l</link>
      <guid>https://dev.to/wangari/leading-a-community-e0l</guid>
      <description>&lt;p&gt;I look at this person and am honestly so proud of who she has become. Today marks exactly 1 year since I started leading &lt;strong&gt;Google Developer Student Clubs Rongo University&lt;/strong&gt;. Back then I was too afraid to talk to people(imposter syndrome is real) because I did not feel skilled enough. I have had an amazing time getting to meet new people, hosting events, interacting with speakers and overall being part of the community.&lt;/p&gt;

&lt;p&gt;My main win from leading this community is that I landed a role as a &lt;strong&gt;Developer Advocate&lt;/strong&gt;. I am currently leading Lux Tech Academy Campus Chapters. This opportunity actually was as a result of interacting with a fellow lead who is doing great things in technology. I also got featured in an international coding series.&lt;/p&gt;

&lt;p&gt;There have been highs and lows but all in all the journey has been one to remember. From introducing new members in the club to seeing them develop the most awesome projects. The lows have been some people giving up along the way, speakers cancelling meetups and much more but I have also seen people rise to their best selves during my tenure.&lt;/p&gt;

&lt;p&gt;My advice to the incoming leads is, there is no formula for leading so just step in there and be awesome. Be very careful when choosing your core team because these people will be your support system throughout your tenure. Do not include your friends in the core team and do not rely on their support; they will always disappoint you.&lt;/p&gt;

&lt;p&gt;My special shout out goes to &lt;strong&gt;Muhammud Samu(Auwal)&lt;/strong&gt; for his unending support and encouragement throughout my tenure. My special thanks also goes to our new GDSC lead &lt;strong&gt;Derrickson Ndambuki&lt;/strong&gt;. This guy never missed an event and was always there to help. Shout out to you &lt;strong&gt;Harun Mwendwa&lt;/strong&gt; for believing in me. I look forward to working with you more.&lt;/p&gt;

&lt;p&gt;I look forward to what this community will achieve in the future. Cheers to more wins and to making the world a better place through technology and collaborations.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Zuri Training</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Fri, 26 Mar 2021 10:10:11 +0000</pubDate>
      <link>https://dev.to/wangari/zuri-training-3j45</link>
      <guid>https://dev.to/wangari/zuri-training-3j45</guid>
      <description>&lt;p&gt;So...here we are. I saw a post on twitter one day about a training that would take place with &lt;strong&gt;Zuri&lt;/strong&gt; in partnership with &lt;strong&gt;Ingessive4Good&lt;/strong&gt; and &lt;strong&gt;HNG&lt;/strong&gt; all over it and decided, 'why not try this? you never know'. Getting that welcome email was the most exciting part for me because I never thought I would be accepted. I am all in it to learn and gain the most because who knows when such an opportunity will come by again.&lt;/p&gt;

&lt;p&gt;We are still working on our first task of creating a CV and uploading some links but am super excited and looking forward to the whole process. Each task has a period of 2 weeks to complete it so as to accommodate those who are not always online. The tasks so far are also very friendly.&lt;/p&gt;

&lt;p&gt;We have started our classes with links being uploaded on YouTube and on zuriboard. We also have awesome &lt;strong&gt;resources&lt;/strong&gt; coming our way. The best part is the &lt;strong&gt;mentors&lt;/strong&gt;. Ever had of patient people, because these ones are super patient and always ready to assist.&lt;/p&gt;

&lt;p&gt;I will keep in touch about the whole process but for now, that's all from me. Chao!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>JavaScript Array Methods</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Fri, 07 Aug 2020 20:47:17 +0000</pubDate>
      <link>https://dev.to/wangari/javascript-array-methods-31</link>
      <guid>https://dev.to/wangari/javascript-array-methods-31</guid>
      <description>&lt;p&gt;For those of us new in programming, arrays may not be so familiar.No worries, we shall dive right into it.&lt;/p&gt;

&lt;p&gt;So what is an &lt;strong&gt;array&lt;/strong&gt;?&lt;br&gt;
An array is a collection of one or more elements of either the same type or different types.The length of an array  is not limited.It lets you store multiple elements in a single variable.The elements can be strings, numbers or boolean.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;let myArray = ["A", "B", "C", 12, true];&lt;/code&gt;&lt;br&gt;
&lt;code&gt;//shows an array with 3 strings, 1 number and a boolean value&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Array Methods
&lt;/h3&gt;

&lt;p&gt;Every method in an array causes an impact; it changes the array in one way or another.We will look at 3 array methods.These are: map, filter and reduce.&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;map()&lt;/strong&gt; or &lt;strong&gt;Array.prototype.map()&lt;/strong&gt; creates a new array with the results of calling a function for every array element.It does not change the original array.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;let myNumbers = [20, 21, 22];&lt;br&gt;
let myArray = myNumbers.map(multiply = (num) =&amp;gt; num * 2);&lt;br&gt;
console.log(myArray);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;//myArray returns 40, 42,44&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;filter()&lt;/strong&gt; or &lt;strong&gt;Array.prototype.filter()&lt;/strong&gt; creates a new array containing only the elements for which the filtered function returns true.It also does not mutate or change the original array.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;const names = ["Susan", "Jane", "John", "Tom"];&lt;br&gt;
const newNames = names.filter(names =&amp;gt; names.length &amp;lt; 5);&lt;br&gt;
console.log(newNames);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;//newNames returns ["Jane", "John" and "Tom"]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;reduce()&lt;/strong&gt; or &lt;strong&gt;Array.prototype.reduce()&lt;/strong&gt; as the word suggests, it reduces an array to a single value.This is achieved using a callback function that is called on each iteration.&lt;br&gt;
&lt;em&gt;A *callback&lt;/em&gt; function is a function that is passed as a parameter to another function.*It is run inside of the function it was passed into.A callback function accepts 4 arguments.The 1st argument is the accumulator which gets assigned the return value of the callback function from the last iteration.The 2nd argument is the current value which is the current element being processed in an array.The 3rd argument is the index of the current element and the fourth argument is the array upon which reduce() is called upon.The 3rd and 4th arguments are optional.&lt;br&gt;
 A perfect example of where reduce can be used is in adding the elements of an array.&lt;br&gt;
&lt;code&gt;const ourArray = [5, 6, 8];&lt;br&gt;
const reducer = (accumulator, currentValue) =&amp;gt; accumulator + currentValue;&lt;br&gt;
console.log(ourArray.reduce(reducer));&lt;/code&gt;&lt;br&gt;
&lt;code&gt;//this code returns 19&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Its a wrap.I hope we have all learnt how to apply array methods map, filter and reduce.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Principles of Object Oriented Programming</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Mon, 13 Jul 2020 18:06:23 +0000</pubDate>
      <link>https://dev.to/wangari/principles-of-object-oriented-programming-oh7</link>
      <guid>https://dev.to/wangari/principles-of-object-oriented-programming-oh7</guid>
      <description>&lt;p&gt;Object Oriented Programming involves using objects to model real world things that we want to represent inside our programs.&lt;br&gt;
An &lt;strong&gt;object&lt;/strong&gt; is an instance of a class that has methods and properties.&lt;br&gt;
A &lt;strong&gt;class&lt;/strong&gt; is a blueprint of an object.Classes can have many objects.&lt;br&gt;
Let's take a look at the &lt;strong&gt;Principles of Object Oriented Programming&lt;/strong&gt;&lt;br&gt;
1.&lt;strong&gt;Encapsulation&lt;/strong&gt;&lt;br&gt;
This involves enclosing or hiding something.In an object,the methods and properties are enclosed within the object.An object keeps its state private, inside a class.Other objects don't have direct access to this state.To communicate with the object, you should use the methods provided but you cannot change the state of the object.&lt;br&gt;
&lt;strong&gt;for example&lt;/strong&gt;&lt;br&gt;
class bird {&lt;br&gt;
constructor (name, legs) {&lt;br&gt;
this.name = name;&lt;br&gt;
this.id = id;&lt;br&gt;
}&lt;br&gt;
add_Friends(add) {&lt;br&gt;
this.add = add;&lt;br&gt;
}&lt;br&gt;
getDetails() {&lt;br&gt;
console.log(&lt;code&gt;Name is ${this.name}, Friends is ${this.add}&lt;/code&gt;);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
let bird1 = new bird("Hooky", 2);&lt;br&gt;
bird1.add_Friends("Batu");&lt;br&gt;
bird1.getDetails();&lt;br&gt;
2.&lt;strong&gt;Abstraction&lt;/strong&gt;&lt;br&gt;
It involves hiding complex details and showing simple ones.It helps code to be more understandable.&lt;br&gt;
&lt;strong&gt;for example&lt;/strong&gt;&lt;br&gt;
function man (fName, lName) {&lt;br&gt;
let firstName = fName;&lt;br&gt;
let lastName = lName;&lt;/p&gt;

&lt;p&gt;let getDetails_noaccess = function() {&lt;br&gt;
return (&lt;code&gt;My first name is ${firstName}, my last name is ${lastName}&lt;/code&gt;);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;this.getDetails_access = function() {&lt;br&gt;
return (&lt;code&gt;My first name is ${firstName}, my last name is $ {lastName}&lt;/code&gt;);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
let man1 = new man("Samson", "Tunny");&lt;br&gt;
console.log(man1.firstName);&lt;br&gt;
console.log(man1.getDetails_noaccess);&lt;br&gt;
console.log(man1.getdetails_access());&lt;br&gt;
3.&lt;strong&gt;Inheritance&lt;/strong&gt;&lt;br&gt;
It is gaining something from someone else.In Object Oriented Programming, it allows for parent class to pass functionality to a child class hence avoiding repeats.It uses extends to create a subclass of the object.&lt;br&gt;
&lt;strong&gt;for example&lt;/strong&gt;&lt;br&gt;
class person {&lt;br&gt;
constructor(name) {&lt;br&gt;
  this.name = name;&lt;br&gt;
toString() {&lt;br&gt;
return (&lt;code&gt;The name of this person is ${this.name});&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
class student extends person {&lt;br&gt;
constructor(name, id) {&lt;br&gt;
super(name);&lt;br&gt;
this.id = id;&lt;br&gt;
}&lt;br&gt;
toString() {&lt;br&gt;
return (&lt;/code&gt;{super.toString()}, Student ID is ${this.id}`);&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
let student1 = new student("Nyota", 20);&lt;br&gt;
console.log(student1.toString());&lt;br&gt;
4.&lt;strong&gt;Polymorphism&lt;/strong&gt;&lt;br&gt;
It is something having multiple forms.In Object Oriented Programming, it involves the same method being used on different objects. Polymorphism gives us the ability to call the same method on different objects.Each child keeps its own methods as they are.&lt;br&gt;
&lt;strong&gt;for example&lt;/strong&gt;&lt;br&gt;
class A {&lt;br&gt;
display() {&lt;br&gt;
console.log("A is invoked");&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
class B extends A {&lt;br&gt;
display() {&lt;br&gt;
console.log("B is invoked");&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
let a = [new A(), new B()];&lt;br&gt;
a.forEach(function(msg) {&lt;br&gt;
msg.display();&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
These principles are what make JavaScript to be an Object Oriented Language.All these principles are meant to create a better understanding and increase the usability of objects.They also help reduce repetition of code hence leading to clean code.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Diving into Object Oriented Programming</title>
      <dc:creator>Susan Wangari</dc:creator>
      <pubDate>Fri, 10 Jul 2020 06:04:56 +0000</pubDate>
      <link>https://dev.to/wangari/diving-into-object-oriented-programming-2g07</link>
      <guid>https://dev.to/wangari/diving-into-object-oriented-programming-2g07</guid>
      <description>&lt;p&gt;Just like the title,Object Oriented Programming is all about objects.Objects have properties and these are what makes an object.One thing to note is that objects can share properties but have different values for those properties.&lt;/p&gt;

&lt;p&gt;Properties in an object can be accessed in 2 ways:&lt;/p&gt;

&lt;p&gt;-using dot notation&lt;/p&gt;

&lt;p&gt;for example&lt;/p&gt;

&lt;p&gt;let duck = {&lt;br&gt;
  name: "Aflac",&lt;br&gt;
  numLegs: 2&lt;br&gt;
};&lt;br&gt;
console.log(duck.name);&lt;/p&gt;

&lt;p&gt;-using bracket notation&lt;/p&gt;

&lt;p&gt;for example&lt;/p&gt;

&lt;p&gt;let duck = {&lt;br&gt;
  name: "Aflac",&lt;br&gt;
  numLegs: 2&lt;br&gt;
};&lt;br&gt;
console.log(duck[name]);&lt;/p&gt;

&lt;p&gt;Objects have constructors.Constructors are functions that create new objects.They use this keyword to set properties of the object they will create.They are defined with a capitalized name to distinguish them from other functions that are not constructors.Objects properties created with constructors are separated with a semicolon unlike other object properties which are separated with a comma.new operator is used when calling a constructor.&lt;/p&gt;

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

&lt;p&gt;function Bird() {&lt;br&gt;
  this.name = "Albert";&lt;br&gt;
  this.color  = "blue";&lt;br&gt;
  this.numLegs = 2;&lt;br&gt;
  // "this" inside the constructor always refers to the object being created&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;let blueBird = new Bird();&lt;br&gt;
When a constructor function creates a new object,it is an instance of its constructor.instance of allows you to compare an object to a constructor.It returns true if the constructor created the object and false if the constructor did not create the object.&lt;/p&gt;

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

&lt;p&gt;let Bird = function(name, color) {&lt;br&gt;
  this.name = name;&lt;br&gt;
  this.color = color;&lt;br&gt;
  this.numLegs = 2;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;let crow = new Bird("Alexis", "black");&lt;/p&gt;

&lt;p&gt;crow instanceof Bird; // =&amp;gt; true&lt;br&gt;
prototype properties reduce code duplication.They are shared among all instances of an object.&lt;/p&gt;

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

&lt;p&gt;Bird.prototype.numLegs = 2;&lt;br&gt;
console.log(duck.numLegs);  // prints 2&lt;br&gt;
console.log(canary.numLegs);  // prints 2&lt;br&gt;
Using Bird.prototype ensures that you do not have to define numLegs is not defined in both duck and canary.&lt;/p&gt;

&lt;p&gt;Objects have methods.One of these methods is Object.create().&lt;/p&gt;

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

&lt;p&gt;let animal = Object.create(Animal.prototype);&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
