<?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>Forem: Salma</title>
    <description>The latest articles on Forem by Salma (@salmittastyle).</description>
    <link>https://forem.com/salmittastyle</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%2F967946%2F8bea1ee3-0890-4b9a-b71d-2862c2f7b10e.jpg</url>
      <title>Forem: Salma</title>
      <link>https://forem.com/salmittastyle</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/salmittastyle"/>
    <language>en</language>
    <item>
      <title>JavaScript Date: Get Date methods</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Mon, 26 Dec 2022 17:27:23 +0000</pubDate>
      <link>https://forem.com/salmittastyle/javascript-date-get-date-methods-2c4i</link>
      <guid>https://forem.com/salmittastyle/javascript-date-get-date-methods-2c4i</guid>
      <description>&lt;p&gt;To create and manipulate a particular date, we will have to create a date type object which is a built-in object in JavaScript.&lt;/p&gt;

&lt;p&gt;To learn how to create a date type object check the following tutorial:&lt;a href="https://purpose-code.com/javascript-date-create-dates-in-javascript/" rel="noopener noreferrer"&gt;Create Dates in JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Date object has many methods that can be classified into different groups: the methods that allow us to obtain a date, those that allow us to define a date, others that allow us to get the current time, etc.&lt;/p&gt;

&lt;p&gt;In this tutorial we will go through different methods to get the date, month, year, time, minutes, seconds...So the methods we're going to use are called "getters" because they all start with "get".&lt;/p&gt;

&lt;h2&gt;
  
  
  getFullYear() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getFullYear()&lt;/strong&gt; method returns the complete year of a date.&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%2Fekj4qftnfp6b4oe3v4gk.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%2Fekj4qftnfp6b4oe3v4gk.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getMonth() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getMonth()&lt;/strong&gt; method returns the month of a date. This month is returned as a number.&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%2Faconausm1m4u3gtaomzw.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%2Faconausm1m4u3gtaomzw.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the number of the month returned is 2. It does not mean that the month is February, but 2 represents the month's index.&lt;/p&gt;

&lt;p&gt;Because if we were to add all the months from January to December to an array, then the index of January would be 0, and the index of December will be 11.&lt;/p&gt;

&lt;p&gt;So here the &lt;strong&gt;getMonth()&lt;/strong&gt; method returned 2 as an index for the month of March.&lt;/p&gt;

&lt;p&gt;In general, &lt;strong&gt;getMonth()&lt;/strong&gt; method is used to return the current month.&lt;/p&gt;

&lt;h2&gt;
  
  
  getDate() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getDate()&lt;/strong&gt; method returns the day of a date. The day is returned as a number.&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%2Fbp8uqw7kj2pn9poeg89h.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%2Fbp8uqw7kj2pn9poeg89h.PNG" alt=" " width="800" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getHours() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getHours()&lt;/strong&gt; method returns the hours of a date. The hours are between 0 and 23.&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%2F3vsr5tfceincrmh11bcq.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%2F3vsr5tfceincrmh11bcq.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getMinutes() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getMinutes()&lt;/strong&gt; method returns the minutes of a date. The minutes are between 0 and 59.&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%2F11fx9sh4a0e0biuuxolr.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%2F11fx9sh4a0e0biuuxolr.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getSeconds() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getSeconds()&lt;/strong&gt; method returns the seconds of a date. The seconds are also between 0 and 59.&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%2Foia3sommed0srm16g5od.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%2Foia3sommed0srm16g5od.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getDay() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getDay()&lt;/strong&gt; method returns the day of a date (day of month or day of week). The day is returned as a number and this number is between 0 and 6.&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%2Fpi70za55lzzhgl5pb1nm.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%2Fpi70za55lzzhgl5pb1nm.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The number returned here is 4. 4 refers to Thursday.&lt;/p&gt;

&lt;p&gt;If we add all the days of the week to an array like this : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]&lt;/p&gt;

&lt;p&gt;the index 0 will refer to Sunday, and that is because in JavaScript, the first day of the week is Sunday. So index 1 represents Monday, 2 represents Tuesday etc...&lt;/p&gt;

&lt;h2&gt;
  
  
  getTime() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getTime()&lt;/strong&gt; method returns the number of milliseconds since January 1, 1970.&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%2Fav3sr5xyls770sjzq1l3.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%2Fav3sr5xyls770sjzq1l3.PNG" alt=" " width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCFullYear() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCFullYear()&lt;/strong&gt; returns the complete UTC year of a date. The difference between &lt;strong&gt;getFullYear()&lt;/strong&gt; and &lt;strong&gt;getUTCFullYear()&lt;/strong&gt; methods is around new Year time. If the day date is December 31 or January 1, the return value of &lt;strong&gt;getUTCFullYear()&lt;/strong&gt; and &lt;strong&gt;getFullYear()&lt;/strong&gt; may be different as the &lt;strong&gt;getUTCFullYear()&lt;/strong&gt; returns the Year according to the universal time.&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%2Fbuztk7ma0qbpac2wij4t.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%2Fbuztk7ma0qbpac2wij4t.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCMonth() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCMonth()&lt;/strong&gt; returns the UTC Month.&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%2Fqhp8mqe6cnko91p8wct2.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%2Fqhp8mqe6cnko91p8wct2.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCDate() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCDate()&lt;/strong&gt; returns the UTC Date.&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%2Fbzowyhom51mjvf6n1ui2.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%2Fbzowyhom51mjvf6n1ui2.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCDay() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCDay()&lt;/strong&gt; returns the UTC Day as a number. This number is between 0 and 6.&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%2Foeymbzrdser04ot6za3w.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%2Foeymbzrdser04ot6za3w.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 22nd of December is a Thursday. Here the number returned is 4, and 4 refers to Thursday as explained in the &lt;strong&gt;getDay()&lt;/strong&gt; method.&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCHours() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCHours()&lt;/strong&gt; returns the UTC Hour. If you use &lt;strong&gt;getHours()&lt;/strong&gt; instead &lt;strong&gt;getUTCHours()&lt;/strong&gt; method, you will get the local time that is on your computer. Because &lt;strong&gt;getHours()&lt;/strong&gt; returns the local time. &lt;/p&gt;

&lt;p&gt;However if you use the &lt;strong&gt;getUTCHours()&lt;/strong&gt;, you will get the UTC time instead.&lt;/p&gt;

&lt;p&gt;The UTC time might be different from the local time due to the time difference.&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%2F5y6c5sl1olvxudnwh5o3.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%2F5y6c5sl1olvxudnwh5o3.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So here the UTC time is 3PM while on my computer I have 4 PM. So my time zone is UTC+1.&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCMinutes() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCMinutes()&lt;/strong&gt; returns UTC minutes.&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%2F6r07s6cqblrwk34jn9w9.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%2F6r07s6cqblrwk34jn9w9.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  getUTCSeconds() Method
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;getUTCSeconds()&lt;/strong&gt; returns UTC seconds.&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%2F0c6xcmzerv9pbrafvmv7.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%2F0c6xcmzerv9pbrafvmv7.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;To retrieve date properties like hours, minutes, seconds, time… the &lt;strong&gt;Date()&lt;/strong&gt; object allows us to do that through the get methods.&lt;/p&gt;

&lt;p&gt;The following get methods get back the local hours, minutes, seconds, day, time…:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;getDate()&lt;/li&gt;
&lt;li&gt;getFullYear()&lt;/li&gt;
&lt;li&gt;getMonth()&lt;/li&gt;
&lt;li&gt;getDay()&lt;/li&gt;
&lt;li&gt;getHours()&lt;/li&gt;
&lt;li&gt;getMinutes()&lt;/li&gt;
&lt;li&gt;getSeconds()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following get methods get back the UTC (Universal time and date) hours, minutes, seconds, day, time…:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;getUTCDate()&lt;/li&gt;
&lt;li&gt;getUTCFullYear()&lt;/li&gt;
&lt;li&gt;getUTCMonth()&lt;/li&gt;
&lt;li&gt;getUTCDay()&lt;/li&gt;
&lt;li&gt;getUTCHours()&lt;/li&gt;
&lt;li&gt;getUTCMinutes()&lt;/li&gt;
&lt;li&gt;getUTCSeconds()&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/javascript-date-create-dates-in-javascript/" rel="noopener noreferrer"&gt;JavaScript Date: Create Dates in JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/5-ways-to-declare-a-function-in-javascript/" rel="noopener noreferrer"&gt;5 ways to declare a function in JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-loop-through-an-array-in-javascript/" rel="noopener noreferrer"&gt;How to loop through an array in JavaScript?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/understanding-javascript-objects-from-basic-concepts-to-practical-usage/" rel="noopener noreferrer"&gt;Understanding JavaScript Objects: From Basic Concepts to Practical Usage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/javascript-object-constructor-function/" rel="noopener noreferrer"&gt;Object constructor functions: How does the Javascript constructor work?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/fetch-api-send-data-from-front-end-to-back-end/" rel="noopener noreferrer"&gt;Fetch API: Send data from front-end to back-end&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How Long Does It Take to Learn JavaScript?</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sun, 11 Dec 2022 14:52:09 +0000</pubDate>
      <link>https://forem.com/salmittastyle/how-long-does-it-take-to-learn-javascript-19n5</link>
      <guid>https://forem.com/salmittastyle/how-long-does-it-take-to-learn-javascript-19n5</guid>
      <description>&lt;p&gt;JavaScript is a programming language that allows web developers to create interactive websites. If you want to become a web developer, learning JavaScript is essential.&lt;/p&gt;

&lt;p&gt;It is a very versatile language. It can be used to build desktop applications, mobile apps, games, and even embedded systems. In addition, it is also widely supported across browsers and operating systems.&lt;/p&gt;

&lt;p&gt;JavaScript has evolved over time, and now supports several new features such as object-oriented programming, event handling, data types, and dynamic typing. This makes it easier to develop applications using the language.&lt;/p&gt;

&lt;p&gt;However, the most popular question among beginners and people who want to start building something nice like a website or an app is : &lt;strong&gt;How long does it take to learn JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article we will understand first what “&lt;strong&gt;Learn&lt;/strong&gt;” means as many people get “&lt;strong&gt;learning&lt;/strong&gt;” confused with “&lt;strong&gt;mastering&lt;/strong&gt;“, and then we will break down how much time exactly is needed to master JavaScript and start doing something with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)- Learning
&lt;/h2&gt;

&lt;p&gt;Learning means gaining or acquiring knowledge of something after studying it or being taught to you.&lt;/p&gt;

&lt;p&gt;This means when you learn something, you become knowledgeable in this subject and have a basic understanding of what this subject is.&lt;/p&gt;

&lt;p&gt;But in no case learning means mastering.&lt;/p&gt;

&lt;p&gt;Same thing for JavaScript. When you ask the question: &lt;strong&gt;How long does it take to learn JavaScript?&lt;/strong&gt; What you’re asking actually is how long you need to have a basic understanding of JavaScript concepts and start understanding how the language works.&lt;/p&gt;

&lt;p&gt;And the answer to this question is it depends.&lt;/p&gt;

&lt;p&gt;It depends on what you would ask?&lt;/p&gt;

&lt;p&gt;Well, it depends on if you’re a self-taught person – Like me 😃 – Or if you’re enrolled in some sort of program or Bootcamp or university…&lt;/p&gt;

&lt;p&gt;But either way, stick around to see exactly the difference between these 2 methods and how much time you will need depending on which situation you’re in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Learn-Code-JavaScript-build-website/dp/B09SNV8VQF?crid=2BT4HQHQVRZ4K&amp;amp;keywords=javascript+games&amp;amp;qid=1670763875&amp;amp;sprefix=javascript+games%2Caps%2C414&amp;amp;sr=8-28&amp;amp;linkCode=li3&amp;amp;tag=purposecode-20&amp;amp;linkId=c4c5a69793235a2206e3c7e544ca0b07&amp;amp;language=en_US&amp;amp;ref_=as_li_ss_il" rel="noopener noreferrer"&gt;&lt;img src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B09SNV8VQF&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=purposecode-20&amp;amp;language=en_US"&gt;&lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fir-na.amazon-adsystem.com%2Fe%2Fir%3Ft%3Dpurposecode-20%26language%3Den_US%26l%3Dli3%26o%3D1%26a%3DB09SNV8VQF" 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%2Fir-na.amazon-adsystem.com%2Fe%2Fir%3Ft%3Dpurposecode-20%26language%3Den_US%26l%3Dli3%26o%3D1%26a%3DB09SNV8VQF" alt="" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- Self-taught way&lt;/strong&gt;&lt;br&gt;
If you’re learning JavaScript all by yourself, then this might take you a little bit longer than expected.&lt;/p&gt;

&lt;p&gt;Usually self-taught people need around 1 year and half to 2 years to grasp the basics of JavaScript.&lt;/p&gt;

&lt;p&gt;And when I say “&lt;strong&gt;grasp the basics&lt;/strong&gt;“, I’m not talking about peeking or skimming the course or the concepts quickly while you’re watching TV and talking to your friend at the same time on the phone while having an eye on the course and the other eye on the computer.&lt;/p&gt;

&lt;p&gt;When I say “&lt;strong&gt;grasp the basics&lt;/strong&gt;” I mean learn JavaScript enough to start feeling comfortable using it because you stuck with it enough to understand the concepts at a deeper level.&lt;/p&gt;

&lt;p&gt;Because to achieve this level of comfort, knowing how a for loop works is not enough. Instead, you should know how a for loop works, and how nested loops work, and how to use a for loop with an object to create various instances of an Object, and if you use a for loop inside a function what will happen, and if you use a function inside a for loop what will happen and so on and so on…&lt;/p&gt;

&lt;p&gt;So you see, just for one concept, which is for loops, there is a lot to understand.&lt;/p&gt;

&lt;p&gt;Of course these are not fixed numbers, we’re all different and for some they might need more than 1 year and half and for others less. But this is the average duration that it takes.&lt;/p&gt;

&lt;p&gt;For me personally, I started feeling comfortable using JavaScript around 2 years and half. It was a long way, and I had to put in a tremendous amount of effort and hard work.&lt;/p&gt;

&lt;p&gt;Also when I’m talking about the “&lt;strong&gt;basics&lt;/strong&gt;“, I really mean the “&lt;strong&gt;basics&lt;/strong&gt;“, like for loops, functions, objects, arrays… I’m not even talking about advanced concepts like how to make an AI, or how to make a blockchain….Because those, once you understand the “basics”, they become very easy to work on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/JavaScript-Crash-Course-Nick-Morgan/dp/1718502265?crid=2BT4HQHQVRZ4K&amp;amp;keywords=javascript+games&amp;amp;qid=1670764061&amp;amp;sprefix=javascript+games%2Caps%2C414&amp;amp;sr=8-43&amp;amp;linkCode=li3&amp;amp;tag=purposecode-20&amp;amp;linkId=b0bd533397bacde1aa7a3cc056990d62&amp;amp;language=en_US&amp;amp;ref_=as_li_ss_il" rel="noopener noreferrer"&gt;&lt;img src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=1718502265&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=purposecode-20&amp;amp;language=en_US"&gt;&lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fir-na.amazon-adsystem.com%2Fe%2Fir%3Ft%3Dpurposecode-20%26language%3Den_US%26l%3Dli3%26o%3D1%26a%3D1718502265" 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%2Fir-na.amazon-adsystem.com%2Fe%2Fir%3Ft%3Dpurposecode-20%26language%3Den_US%26l%3Dli3%26o%3D1%26a%3D1718502265" alt="" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But why is it hard to learn JavaScript by yourself?&lt;/strong&gt;&lt;br&gt;
Simply because you have to figure out everything all alone.&lt;/p&gt;

&lt;p&gt;You have to check hundreds of websites, watch thousands of videos, select the right courses for you by yourself, make your own mistakes, google them hoping you’ll find someone who already had the same problem and found the solution, join forums so that you can ask questions there and see if there is anyone ready to help, understand the code or others code…&lt;/p&gt;

&lt;p&gt;That’s pretty tedious and can quickly become overwhelming and discouraging because you feel lonely and there is nobody you can turn to for help.&lt;/p&gt;

&lt;p&gt;Not to mention that nowadays, there are millions of resources out here, so when you are a beginner and trying to figure out things by yourself, you get lost quickly, because everyone says that this video is the best, or this course is the best, or this website is the best. So you don’t know which one really to trust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- Guided way&lt;/strong&gt;&lt;br&gt;
A guided way to learn JavaScript generally involves a tutor, a coach, a teacher, or paid bootcamps…&lt;/p&gt;

&lt;p&gt;Using this method speeds up the learning process tremendously and has many advantages. But it requires financial investment&lt;/p&gt;

&lt;p&gt;But don’t let that stop you because learning JavaScript pays substantial dividends that make the effort more than worth it…&lt;/p&gt;

&lt;p&gt;Using this method you will need between 6 to 9 months to learn deeply the concepts of JavaScript as the courses and training you will enroll in usually have this duration length.&lt;/p&gt;

&lt;p&gt;There are some platforms you can join that have many JavaScript, HTML, and CSS courses, and you get a certificate by the end of the training period.&lt;/p&gt;

&lt;p&gt;One of them is &lt;strong&gt;eudureka!&lt;/strong&gt; platform. I like this platform because it has courses not only about HTML, CSS, and JS but also about Cloud computing, cyber security, BI…So if you’re interested in any other course you can take it as well. All it requires is an enrollment to your favorite course and you get access to it with the certificate at the end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://click.linksynergy.com/link?id=yz99OvBVXYs&amp;amp;offerid=742306.11929975904&amp;amp;type=2&amp;amp;murl=https%3A%2F%2Fedureka.co%2Fjavascript-jquery-training&amp;amp;LSNSUBSITE=LSNSUBSITE" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.edureka.co%2Fimgver.1517231219%2Fimg%2Fco_img_493_1505909633.png" width="355" height="189"&gt;&lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fad.linksynergy.com%2Ffs-bin%2Fshow%3Fid%3Dyz99OvBVXYs%26bids%3D742306.11929975904%26type%3D2%26subid%3D0" 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%2Fad.linksynergy.com%2Ffs-bin%2Fshow%3Fid%3Dyz99OvBVXYs%26bids%3D742306.11929975904%26type%3D2%26subid%3D0" width="1" height="1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- Mastering
&lt;/h2&gt;

&lt;p&gt;On the other hand, we have mastering.&lt;/p&gt;

&lt;p&gt;Mastering means knowing the subject sufficiently that not only you feel comfortable using it or talking about it, but it becomes a second nature to you.&lt;/p&gt;

&lt;p&gt;Mastering JavaScript does not mean you don’t make mistakes anymore, but rather you are able now to build real websites and apps because not only you understood well the tips and tricks, but you are at a stage where you can understand other people’s code and spot errors, pick up new tricks or lessons quickly, help others and why not tutoring them and discuss anything about JavaScript with ease.&lt;/p&gt;

&lt;p&gt;This phase does not have a timeframe because simply JavaScript is so wide that even if by any chance you master all of it, a new version of JS will change it all as there are always updates and new libraries and frameworks.&lt;/p&gt;

&lt;p&gt;However, you can master a part of JavaScript, and that is when you know exactly what you want to do and start working on it from the beginning.&lt;/p&gt;

&lt;p&gt;For example, if you know that you love games, and you want to build a career as a game developer, then you know which part of JavaScript you’ll need to learn and focus on the most. And for those who are fond of Blockchain, for sure they will not focus on the same techniques and libraries as a game developer, they will have to concentrate on other types of libraries, but that is what will make them masters in their area, which is Blockchain.&lt;/p&gt;

&lt;p&gt;And to be a master in an area or a part of JavaScript, the minimum duration is one year depending on which area you chose to focus on. But still, the truth is, when it comes to mastering, the process is a never-ending with JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- What should I know before starting to learn JavaScript?
&lt;/h2&gt;

&lt;p&gt;To learn JavaScript, you don't have to know any other programming language, but it would be better if you know HTML and CSS first. &lt;/p&gt;

&lt;p&gt;JavaScript is used to create dynamic websites, so it makes sense to have a basic familiarity with other web page building blocks like HTML and CSS. &lt;/p&gt;

&lt;p&gt;Also, don't forget that you will be manipulating DOM elements with JavaScript, and DOM elements simply mean HTML elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.udemy.com/course/web-developement-for-beginners-build-websites-from-scratch/" rel="noopener noreferrer"&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%2Fw10co46laoowqm7mbrxz.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4)- How Much Time You Have to Dedicate to Learning JS?
&lt;/h2&gt;

&lt;p&gt;It’s no secret that the more time you dedicate to learning, the quicker you’ll be able to pick up the skills needed to code with JavaScript.&lt;/p&gt;

&lt;p&gt;Learning how to program requires dedication. You must put in the time to practice and develop your coding skills. However, if you do not take advantage of a structured course, you may find yourself struggling to keep pace with others who are better versed in JavaScript. A structured course provides a curriculum that slowly builds upon your knowledge. By enrolling in a course, you begin with basic concepts and move through them one step at a time. Instructors also help you out when you run into trouble. They can offer guidance and assistance so that you can master the material.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.com/Web-Development-beginners-Programming-development/dp/B08BWCL2RW?_encoding=UTF8&amp;amp;qid=1670770018&amp;amp;sr=8-13&amp;amp;linkCode=li3&amp;amp;tag=purposecode-20&amp;amp;linkId=011ab4fbe8a3dc5c085cf8981660114a&amp;amp;language=en_US&amp;amp;ref_=as_li_ss_il" rel="noopener noreferrer"&gt;&lt;img src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B08BWCL2RW&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=purposecode-20&amp;amp;language=en_US"&gt;&lt;/a&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fir-na.amazon-adsystem.com%2Fe%2Fir%3Ft%3Dpurposecode-20%26language%3Den_US%26l%3Dli3%26o%3D1%26a%3DB08BWCL2RW" 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%2Fir-na.amazon-adsystem.com%2Fe%2Fir%3Ft%3Dpurposecode-20%26language%3Den_US%26l%3Dli3%26o%3D1%26a%3DB08BWCL2RW" alt="" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-start-coding-the-ultimate-guide-for-beginners/" rel="noopener noreferrer"&gt;How to Start Coding in HTML, CSS, and JS: The Ultimate Guide for Beginners&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-make-money-as-a-web-developer7-income-sources/" rel="noopener noreferrer"&gt;How to make money as a web developer?(7 income sources)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/fetch-api-send-data-from-front-end-to-back-end/" rel="noopener noreferrer"&gt;Fetch API: Send data from front-end to back-end&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/send-form-data-to-the-back-end-node-js/" rel="noopener noreferrer"&gt;Send form data to the back-end (Node JS)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/5-ways-to-declare-a-function-in-javascript/" rel="noopener noreferrer"&gt;5 ways to declare a function in JavaScript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>20 JavaScript Array Methods</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Fri, 09 Dec 2022 20:08:52 +0000</pubDate>
      <link>https://forem.com/salmittastyle/20-javascript-array-methods-503k</link>
      <guid>https://forem.com/salmittastyle/20-javascript-array-methods-503k</guid>
      <description>&lt;p&gt;Arrays are one of the most important concepts in JavaScript.&lt;/p&gt;

&lt;p&gt;Arrays are objects that enable storing a collection of items and data under a single variable name and have the capability to perform a certain operation.&lt;br&gt;
In this article, we'll go through 20 methods we can use with an array to manage the data we have.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1)- pop()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the array methods is the &lt;strong&gt;pop()&lt;/strong&gt; method.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;pop()&lt;/strong&gt; method removes the last element of an array.&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%2Fdyo4lfoto3xi22cp7j26.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%2Fdyo4lfoto3xi22cp7j26.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we console.log the array, it becomes:&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%2F5ibqlw7axgkgvdlkc0cc.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%2F5ibqlw7axgkgvdlkc0cc.PNG" alt=" " width="376" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2)- push()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike &lt;strong&gt;pop()&lt;/strong&gt; method, &lt;strong&gt;push()&lt;/strong&gt; method adds an element to the end of an array.&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%2F5apw4dr9tcmdyj5ywnm4.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%2F5apw4dr9tcmdyj5ywnm4.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The array now becomes:&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%2Ff94zedolmzdc2ofu0rae.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%2Ff94zedolmzdc2ofu0rae.PNG" alt=" " width="547" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3)- shift()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;shift()&lt;/strong&gt; method removes the first element of an array.&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%2F1z777cxjtk2axewo4x1e.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%2F1z777cxjtk2axewo4x1e.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The array becomes then:&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%2Fuk3ddz2eo2j2y0mgjmhv.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%2Fuk3ddz2eo2j2y0mgjmhv.PNG" alt=" " width="387" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4)- unshift()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;unshift()&lt;/strong&gt; method adds an element at the beginning of an array.&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%2F4wcl3tme8lr4r5ia5exu.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%2F4wcl3tme8lr4r5ia5exu.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The array becomes:&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%2Fovdy060tsdq086oeyuer.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%2Fovdy060tsdq086oeyuer.PNG" alt=" " width="534" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5)- splice()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To add or remove elements to/from a specific position in the array the &lt;strong&gt;splice()&lt;/strong&gt; method allows us to do that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- Add an element to a specific position&lt;/strong&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%2Fe1qv2oauh98ki33vlmhm.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%2Fe1qv2oauh98ki33vlmhm.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To add an element to a specific position we use &lt;strong&gt;splice()&lt;/strong&gt; method. It takes 3 parameters at least:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first parameter is where, or at what position we want to add our elements. In this example we want to add them at position 2, which means after "Iphone", hence "2" is added as first parameter of &lt;strong&gt;splice()&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The second parameter reflects how many elements we want to delete. In this example we don't want to delete any element, so we added "0" as second parameter of &lt;strong&gt;splice()&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The third parameter and beyond are the elements that we want to add.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the array becomes:&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%2Fqlaq90bt4uy4gny57laf.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%2Fqlaq90bt4uy4gny57laf.PNG" alt=" " width="613" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- Remove a specific element&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;splice()&lt;/strong&gt; method, unlike &lt;strong&gt;pop()&lt;/strong&gt; and &lt;strong&gt;shift()&lt;/strong&gt; methods, allows us to remove any element from an array. All we have to do is to specify its position.&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%2Fzpxge53w0dlwjip05ep3.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%2Fzpxge53w0dlwjip05ep3.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To remove a specific element from the array we use splice() method. It takes 2 parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first parameter is where, or at what position we want to add our elements. But here we will use the first parameter to specify
from where the "delete" operation should start. In this example it should start from position 2.&lt;/li&gt;
&lt;li&gt;The second parameter is to specify how many elements should be removed. In this example we want to remove one element.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end we have the following array:&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%2F7n9weomspdvgyc1k3k5n.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%2F7n9weomspdvgyc1k3k5n.PNG" alt=" " width="355" height="46"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;6)- map()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;map()&lt;/strong&gt; method generally accepts a function as argument. This function runs through each element of the array and returns a new array based on these elements.&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%2F45fn9w9wn41f0ke0p4vn.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%2F45fn9w9wn41f0ke0p4vn.PNG" alt=" " width="800" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So here the function took every element of the array "&lt;strong&gt;numbers&lt;/strong&gt;" and multiplied it by 2, and at the end returned a new array with the new results.&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%2Fp37j02fue86ku6nk2yug.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%2Fp37j02fue86ku6nk2yug.PNG" alt=" " width="235" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7)- filter()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;filter()&lt;/strong&gt; method returns a new array that contains all the elements that pass the test.&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%2Ff7zfmnbokp0ple1xdmvb.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%2Ff7zfmnbokp0ple1xdmvb.PNG" alt=" " width="800" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the function returns the age if the age is greater than 30 and stores it in the new array.&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%2Fc6c09maf3z20f5pafpxs.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%2Fc6c09maf3z20f5pafpxs.PNG" alt=" " width="203" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8)- concat()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;concat()&lt;/strong&gt; method helps us merge arrays to get one array.&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%2Fj1jj3zr1qbrvf7ghabtt.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%2Fj1jj3zr1qbrvf7ghabtt.PNG" alt=" " width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The new array is:&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%2F1j3iqm1rfewxer8gn15j.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%2F1j3iqm1rfewxer8gn15j.PNG" alt=" " width="700" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9)- fill()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To fill an array with a static value we use &lt;strong&gt;fill()&lt;/strong&gt; method.&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%2F0wuhrhjx59iz76v4zjok.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%2F0wuhrhjx59iz76v4zjok.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The array becomes:&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%2F7vopa94jgcnfs9tg1b8x.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%2F7vopa94jgcnfs9tg1b8x.PNG" alt=" " width="465" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also add the static value at a specific position of the array.&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%2Fylrnq2von5tsx1w92lv2.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%2Fylrnq2von5tsx1w92lv2.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The array becomes:&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%2F1woa9ipo420eg48lopz5.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%2F1woa9ipo420eg48lopz5.PNG" alt=" " width="376" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To add static values to specific positions of the array we pass the &lt;strong&gt;fill()&lt;/strong&gt; method some parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first parameter is the static value, in this example it is "Kiwi".&lt;/li&gt;
&lt;li&gt;The second parameter is starting from which position this value should be added, in this example it should be added starting from position 2.&lt;/li&gt;
&lt;li&gt;The third value is at what position w should stop adding the static value. In this example it is at position 4.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;10)- join()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;join()&lt;/strong&gt; method joins the elements of the array and returns a string.&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%2Fphi1drbzuadrvmitp2ss.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%2Fphi1drbzuadrvmitp2ss.PNG" alt=" " width="800" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2F5v15a56vwvk6jkzyjrj9.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%2F5v15a56vwvk6jkzyjrj9.PNG" alt=" " width="264" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;join()&lt;/strong&gt; method accepts a separator that is added between the parenthesis. In this example we chose the backslash "/" as separator, we can choose any separator we want. &lt;/p&gt;

&lt;p&gt;If we choose a hyphen as separator the code will be:&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%2F0jjfn3ceadza0i0jyd7i.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%2F0jjfn3ceadza0i0jyd7i.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And so the results will be:&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%2Fkt27k56pqofodzeczc18.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%2Fkt27k56pqofodzeczc18.PNG" alt=" " width="260" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11)- IndexOf()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;indexOf()&lt;/strong&gt; method returns the first index at which a given element can be found in the array. If the element is not in the array, then the method returns -1.&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%2Fas1gxb6abp6prrlhry6k.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%2Fas1gxb6abp6prrlhry6k.PNG" alt=" " width="800" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2Ffdd2i05rf74ly2snwn96.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%2Ffdd2i05rf74ly2snwn96.PNG" alt=" " width="300" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the index of "Kiwi" is 2. Because &lt;strong&gt;indexOf()&lt;/strong&gt; returns the index of the first occurrence of the element. If we try this with "apple" we'll have 3 as an index.&lt;/p&gt;

&lt;p&gt;However, what about if we have the same element repeated twice or 3 times or more in the array, and we want to know the index of the second occurrence or third or fourth occurrence?&lt;/p&gt;

&lt;p&gt;Let's see that with "Kiwi". "Kiwi" is repeated twice. So the index of the first "Kiwi" is 2. To know the index of the second "Kiwi" we'll add:&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%2Frzwtr2madaxzw4r31802.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%2Frzwtr2madaxzw4r31802.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3 represents the start point from where the array should start looking. And here it should start after the first "Kiwi", which means at position 3.&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2Fm8tabwmjhgclle7vj4nj.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%2Fm8tabwmjhgclle7vj4nj.PNG" alt=" " width="305" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12)- includes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;includes()&lt;/strong&gt; helps to check if an element is in the array. If so, it returns true.&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%2Fn85ru1u6nmtgw5ihgcyv.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%2Fn85ru1u6nmtgw5ihgcyv.PNG" alt=" " width="800" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13)- reverse()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;reverse()&lt;/strong&gt; method reverses the order of the array elements.&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%2Fl75zkem0oiejf24l7bd0.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%2Fl75zkem0oiejf24l7bd0.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2Fuywqr35ubnnoxtzl2h7n.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%2Fuywqr35ubnnoxtzl2h7n.PNG" alt=" " width="518" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14)- every()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;every()&lt;/strong&gt; method returns true if all the elements of the array pass the test. This method accepts a function that runs through all the array's elements.&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%2Flv3ko1hk6jbas3kr1r4w.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%2Flv3ko1hk6jbas3kr1r4w.PNG" alt=" " width="800" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15)- some()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;some()&lt;/strong&gt; is a method that returns true if at least one element in the array passes the test given by the function passed as argument.&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%2Fxp523et3fq61ih59y91r.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%2Fxp523et3fq61ih59y91r.PNG" alt=" " width="800" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;16)- at()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;at()&lt;/strong&gt; returns the element that is in the index specified in the parenthesis.&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%2Fkjrnun7mp408mr0galf3.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%2Fkjrnun7mp408mr0galf3.PNG" alt=" " width="800" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2F9yidvx2donh9nmlwam46.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%2F9yidvx2donh9nmlwam46.PNG" alt=" " width="218" height="42"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;17)- of()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method creates a new array from a variable number of arguments, regardless of number or type of the arguments.&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%2Fyuo9yb5joytxvctc1czs.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%2Fyuo9yb5joytxvctc1czs.PNG" alt=" " width="800" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have an array that is created:&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%2Fjthoy7ltf1833sphwj82.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%2Fjthoy7ltf1833sphwj82.PNG" alt=" " width="466" height="48"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;18)- slice()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;slice()&lt;/strong&gt; method returns a slice or a part of the array.&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%2Fyt4jpzqvfq7n852jfqyc.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%2Fyt4jpzqvfq7n852jfqyc.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;br&gt;
The new portion of the array will be:&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%2Fvd5ybn0loctr6gm5yv20.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%2Fvd5ybn0loctr6gm5yv20.PNG" alt=" " width="254" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first argument that the slice() method takes is the beginning the returned array should start from. Here the returned array should start from index 1. &lt;/p&gt;

&lt;p&gt;The second argument is the end where the returned array should stop. Here it should stop at index 3. &lt;/p&gt;

&lt;p&gt;The end is not included, which means if we want the slice() method to stop at index 3, then the returned array will contain elements until index 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;19)- Array.isArray()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method returns true if the declared variable is an array.&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%2Fco6mw2lt71d2s8tm3bli.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%2Fco6mw2lt71d2s8tm3bli.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;20)- delete()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This methods deletes an element from the array by specifying the index we want to be deleted. However, the **delete() **method leaves undefined or empty holes in the array after the element is deleted.&lt;/p&gt;

&lt;p&gt;Which means even if the element is deleted, the length of the array does not change. &lt;/p&gt;

&lt;p&gt;If for example the length of the array is 5, then after an element is being deleted the length will stay 5.&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%2F779drvpnu89hvou6p5sb.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%2F779drvpnu89hvou6p5sb.PNG" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2Fpyaqeluxl4jwg43qdhyr.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%2Fpyaqeluxl4jwg43qdhyr.PNG" alt=" " width="433" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is not advisable to use this method to delete elements from an array. &lt;/p&gt;

&lt;p&gt;To delete an element from an array use &lt;strong&gt;splice()&lt;/strong&gt; method instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/html-tags-cheatsheet/" rel="noopener noreferrer"&gt;HTML tags CheatSHeet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/what-are-the-different-types-of-inputs-in-html-forms/" rel="noopener noreferrer"&gt;What are the different types of inputs in HTML forms?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/understanding-javascript-objects-from-basic-concepts-to-practical-usage/" rel="noopener noreferrer"&gt;Understanding JavaScript Objects: From Basic Concepts to Practical Usage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-loop-through-an-array-in-javascript/" rel="noopener noreferrer"&gt;How to loop through an array in JavaScript?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/5-ways-to-declare-a-function-in-javascript/" rel="noopener noreferrer"&gt;5 ways to declare a function in JavaScript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>5 ways to declare a function in JavaScript</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Thu, 01 Dec 2022 19:34:07 +0000</pubDate>
      <link>https://forem.com/salmittastyle/5-ways-to-declare-a-function-in-javascript-5ehh</link>
      <guid>https://forem.com/salmittastyle/5-ways-to-declare-a-function-in-javascript-5ehh</guid>
      <description>&lt;p&gt;JavaScript functions are used to perform actions when certain events occur. They are also called methods.&lt;/p&gt;

&lt;p&gt;A JavaScript function is usually a block of code that contains a group of instructions to execute.&lt;/p&gt;

&lt;p&gt;There are many ways to declare a simple function in JavaScript. In this tutorial, we will explore them with some examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)- Ways to declare functions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;a)- Function declaration&lt;/strong&gt;&lt;br&gt;
Also called a function statement or a function definition, is the most common way of declaring a function in JavaScript.&lt;/p&gt;

&lt;p&gt;The function declaration method simply means that we will declare the function using the keyword function followed by the name of the function itself like below:&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%2Fxgqfhg7laks61wy36q3f.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%2Fxgqfhg7laks61wy36q3f.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So here “&lt;strong&gt;function&lt;/strong&gt;” is the keyword, and “&lt;strong&gt;course&lt;/strong&gt;” is the name of the function.&lt;/p&gt;

&lt;p&gt;If we want to call the function all we have to do is write its name followed by the parenthesis like below:&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%2Fggflqxqx9lri76gp6dd9.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%2Fggflqxqx9lri76gp6dd9.PNG" alt=" " width="800" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A function can take arguments. If we have dynamic data, we can pass the function as many parameters as we want.&lt;/p&gt;

&lt;p&gt;Let’s say that for function &lt;strong&gt;course()&lt;/strong&gt; whenever we call it we want it to display “&lt;strong&gt;Welcome to this tutorial&lt;/strong&gt;” plus the name of the student.&lt;/p&gt;

&lt;p&gt;The name of the student can change, as we can have 10 or 20 or 30 students….&lt;/p&gt;

&lt;p&gt;So to do that we will pass a parameter called “&lt;strong&gt;studentName&lt;/strong&gt;” to the function.&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%2F6syje82m0gl0sylj3kll.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%2F6syje82m0gl0sylj3kll.PNG" alt=" " width="800" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now for the function to display what we want, at the moment when we will call it we should pass it the name of the student.&lt;/p&gt;

&lt;p&gt;Let’s say that the student’s name is Thomas.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2F4bxk5f0bbdcd4asfp6z7.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%2F4bxk5f0bbdcd4asfp6z7.PNG" alt=" " width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- Anonymous function&lt;/strong&gt;&lt;br&gt;
When a function is declared anonymously, it means that the function does not have any name.&lt;/p&gt;

&lt;p&gt;Unlike in the general declaration function where a name is given to a function, in the anonymous function there is no name.&lt;/p&gt;

&lt;p&gt;An anonymous function is declared using the &lt;strong&gt;function&lt;/strong&gt; keyword only, like below:&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%2Frg56b5tqeklxyn7u7dve.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%2Frg56b5tqeklxyn7u7dve.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the function does not have any name. That’s why it is called anonymous.&lt;/p&gt;

&lt;p&gt;However, as an anonymous function is not accessible after its initial creation, and as it can only be accessed via a variable, we will store it in a variable that we’ll call course, and this is what we’ll see in the next paragraph.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)- Function expression&lt;/strong&gt;&lt;br&gt;
The function expression method allows us to create an anonymous function that doesn’t have any function name.&lt;/p&gt;

&lt;p&gt;Below is an example of an anonymous function expression. let’s see the code:&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%2Fvtnknmnw51rduymb6yd8.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%2Fvtnknmnw51rduymb6yd8.PNG" alt=" " width="800" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the variable &lt;strong&gt;course&lt;/strong&gt; stores an anonymous function.&lt;/p&gt;

&lt;p&gt;So the anonymous function is invoked by calling out the variable with trailing parenthesis and semicolons.&lt;/p&gt;

&lt;p&gt;The code below will call the function:&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%2Fyrhx6neawgx9kvcd1mbv.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%2Fyrhx6neawgx9kvcd1mbv.PNG" alt=" " width="800" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d)- Arrow function&lt;/strong&gt;&lt;br&gt;
This method is a cleaner way of creating JavaScript functions.&lt;/p&gt;

&lt;p&gt;So instead of declaring a function like this:&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%2F13py98jnh3fwg2gttscc.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%2F13py98jnh3fwg2gttscc.PNG" alt=" " width="800" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can declare it like this:&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%2Fxze3robm70vc5qae4hkp.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%2Fxze3robm70vc5qae4hkp.PNG" alt=" " width="800" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, as the arrow function does not have a name, it should be stored in a variable if we want to invoke it later, just like the function expression.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2Fhymazpq277pv7wueby8s.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%2Fhymazpq277pv7wueby8s.PNG" alt=" " width="800" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Arrow functions provide a concise syntax for defining anonymous functions. An arrow function expression has a shorter syntax compared to other ways of declaring functions.&lt;/p&gt;

&lt;p&gt;An Arrow function can also have arguments like this:&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%2Fiqjyimpceg8segot1z0o.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%2Fiqjyimpceg8segot1z0o.PNG" alt=" " width="800" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When creating an arrow function, the parenthesis pairs and curly braces are optional for a single function parameter and a single statement.&lt;/p&gt;

&lt;p&gt;If there are many instructions that the function should execute, then these instructions should be wrapped inside curly braces:&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%2F4mq7kspis1fys6pu4hxa.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%2F4mq7kspis1fys6pu4hxa.PNG" alt=" " width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e)- Constructor function&lt;/strong&gt;&lt;br&gt;
Another way to declare a function is by using the Function constructor with the new keyword.&lt;/p&gt;

&lt;p&gt;Let’s have a look at the syntax first:&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%2Feagtyyrq49yfqwf04zxs.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%2Feagtyyrq49yfqwf04zxs.PNG" alt=" " width="800" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JavaScript has a built-in constructor Object called Function that can be used to declare and create functions.&lt;/p&gt;

&lt;p&gt;This constructor can take any number of arguments. For this example we passed it 2 arguments which are “&lt;strong&gt;a&lt;/strong&gt;” and “&lt;strong&gt;b&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;The last parameter is where the instructions that the function is supposed to execute should be added. It is there where goes the function body.&lt;/p&gt;

&lt;p&gt;The general syntax is:&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%2Figjfyxm7l9cb2bzksw91.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%2Figjfyxm7l9cb2bzksw91.PNG" alt=" " width="800" height="73"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in this example we created a function using the Function object, its name is sum().&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- Which way is better?
&lt;/h2&gt;

&lt;p&gt;There is no answer to this question because all depends on the situation and the function code.&lt;/p&gt;

&lt;p&gt;You can use any method or function type you want and all of them will give you the same results.&lt;/p&gt;

&lt;p&gt;so if you’re comfortable with either approach, feel free to pick whichever you prefer. However, I’d recommend sticking with the arrow function type whenever possible, as it offers better performance and readability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/javascript-object-constructor-function/" rel="noopener noreferrer"&gt;Object constructor functions: How does the Javascript constructor work?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/send-form-data-to-database/" rel="noopener noreferrer"&gt;Send form data received in the backend to the database (MongoDB)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/send-form-data-to-the-back-end-node-js/" rel="noopener noreferrer"&gt;Send form data to the back-end (Node JS)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/get-the-data-back-from-the-database-mongodb-and-display-it-on-the-front-end/" rel="noopener noreferrer"&gt;Get the data back from the database (MongoDB) and display it on the front-end&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/send-data-from-backend-node-js-to-mongodb/" rel="noopener noreferrer"&gt;How to send data from back-end(Node JS) to MongoDB database?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>learning</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Audio and Video HTML Tutorial – Learn how to add sound effects, videos and Youtube videos to your website</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sat, 26 Nov 2022 16:32:55 +0000</pubDate>
      <link>https://forem.com/salmittastyle/audio-and-video-html-tutorial-learn-how-to-add-sound-effects-videos-and-youtube-videos-to-your-website-44gb</link>
      <guid>https://forem.com/salmittastyle/audio-and-video-html-tutorial-learn-how-to-add-sound-effects-videos-and-youtube-videos-to-your-website-44gb</guid>
      <description>&lt;p&gt;Is it possible to embed audio and video files into web pages without using Flash or other plugins?&lt;/p&gt;

&lt;p&gt;HTML5 is a new standard for creating websites and apps. It was developed by the World Wide Web Consortium (W3C) and aims to provide developers with better tools for building cross-platform applications. The W3C has also created a specification called Web Audio API that allows developers to create interactive audio experiences within their sites.&lt;/p&gt;

&lt;p&gt;Audio files, as well as video files, are now part of HTML5, allowing you to add audio content and videos to your site without having to rely on external plug-ins. This means that you don’t need to download additional software to play music or listen to podcasts. Just some custom controls are enough to add the media.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)- Video
&lt;/h2&gt;

&lt;p&gt;In HTML, to add a video to your website all you have to do is use the &lt;code&gt;&amp;lt;video&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Let’s take a simple HTML page with only a heading and a video.&lt;/p&gt;

&lt;p&gt;The code is:&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%2Fofoc9xfrf4wrfikupdow.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%2Fofoc9xfrf4wrfikupdow.PNG" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;br&gt;
Inside the &lt;code&gt;&amp;lt;video&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt; tag we added the &lt;code&gt;&amp;lt;source&amp;gt;&amp;lt;/source&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;source&amp;gt;&amp;lt;/source&amp;gt;&lt;/code&gt; tag is used to specify which video should be displayed, or in other words, to determine the source element of the video.&lt;/p&gt;

&lt;p&gt;For that, the &lt;code&gt;&amp;lt;source&amp;gt;&amp;lt;/source&amp;gt;&lt;/code&gt; tag accepts one essential attribute which is the &lt;strong&gt;src&lt;/strong&gt; attribute. The &lt;strong&gt;src&lt;/strong&gt; attribute is the one that takes in the name of the video we want to display plus the extension of the video.&lt;/p&gt;

&lt;p&gt;Another attribute can be added to determine the &lt;strong&gt;type&lt;/strong&gt; of the video, this attribute is type but it is optional.&lt;/p&gt;

&lt;p&gt;So in the browser we have:&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%2Flpkqew8srbe0s2pongpl.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%2Flpkqew8srbe0s2pongpl.PNG" alt=" " width="722" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see here, the video is now added to the browser. But there are 2 main problems here:&lt;/p&gt;

&lt;p&gt;The first problem is that the video is taking up too much space, and the second problem is that there are no controls. So if we want to play the video or pause it or turn up the volume, we can’t.&lt;/p&gt;

&lt;p&gt;Let’s see how to fix these problems.&lt;/p&gt;

&lt;p&gt;For the first one, regarding the width of the video, we will just set a width using CSS. You can also set a height if you want , but in this example, we will add a width only:&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%2Fq8sup8xm7k83h7uytc5r.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%2Fq8sup8xm7k83h7uytc5r.PNG" alt=" " width="800" height="160"&gt;&lt;/a&gt;&lt;br&gt;
So the video now looks like this:&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%2F3alp93lugaddgndhkcfy.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%2F3alp93lugaddgndhkcfy.PNG" alt=" " width="789" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s solve the second problem, which is to add the video controls.&lt;/p&gt;

&lt;p&gt;To add video controls simply we will add the controls attribute inside the &lt;code&gt;&amp;lt;video&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt; tag like this:&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%2Fh131hsdbms3a7s5i327d.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%2Fh131hsdbms3a7s5i327d.PNG" alt=" " width="800" height="406"&gt;&lt;/a&gt;&lt;br&gt;
So the video now becomes:&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%2Faujdq489hdpqoat7ewlz.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%2Faujdq489hdpqoat7ewlz.PNG" alt=" " width="653" height="387"&gt;&lt;/a&gt;&lt;br&gt;
As you have noticed at the bottom of the video you have now this bar where you can play, pause the video, turn up the volume(volume controls)…&lt;/p&gt;

&lt;p&gt;There are other attributes you can add to the &lt;code&gt;&amp;lt;video&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt; tag to have more control over the video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- muted&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To play the video without any sound the muted attribute should be added like this:&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%2Fany0opjhrqsarygh14d8.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%2Fany0opjhrqsarygh14d8.PNG" alt=" " width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if you refresh the browser and play the video, you will see that the sound is muted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- autoplay&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;autoplay&lt;/strong&gt; attribute makes the video play automatically when the page is displayed. However, there are some “autoplay policies”: Recently, many browsers allow the video to be automatically played only if it is muted, and that is because when the user loads the page and the video is suddenly played the sound can be annoying. So to counter this problem, browsers now authorize the video to be played automatically if the sound is muted. Which is the case for Chrome autoplay policies for example.&lt;/p&gt;

&lt;p&gt;The code is:&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%2Fvfp8gagysu5ts24rgkqr.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%2Fvfp8gagysu5ts24rgkqr.PNG" alt=" " width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if you refresh the page you will see that the video plays on the page load.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)- loop&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To play the video again and again in a loop you can add the loop attribute.&lt;br&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%2Fjvh0xp5jk7zneboxsqen.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%2Fjvh0xp5jk7zneboxsqen.PNG" alt=" " width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if you refresh the page and play the video, at the end you will see that the video will be played once again automatically, you don’t have to do anything.&lt;/p&gt;

&lt;p&gt;That makes the video playback easy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d)- poster&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;poster attribute allows us to add an image to the video that will be shown as long as the video is not played yet or while the video is downloading.&lt;/p&gt;

&lt;p&gt;It is like a thumbnail for Youtube videos for example.&lt;/p&gt;

&lt;p&gt;Let’s say that for this video I want an image of a dog to be shown.&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%2F4kpahaqnuery8s2ur2zv.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%2F4kpahaqnuery8s2ur2zv.PNG" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2F9dp504saihz6qu09hdvi.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%2F9dp504saihz6qu09hdvi.PNG" alt=" " width="699" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So as you can see, as long as the user does not hit the play button, the dog picture will be shown. But if the user plays the video, then the dog picture will disappear.&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- Audio
&lt;/h2&gt;

&lt;p&gt;To add an audio to the HTML page we’ll use the same code we used to add a video, except this time instead of using &lt;code&gt;&amp;lt;video&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt; tag we’ll use &lt;code&gt;&amp;lt;audio&amp;gt;&amp;lt;/audio&amp;gt;&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;So the code is:&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%2Fe9nbuvqhfykxy4p1uv6o.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%2Fe9nbuvqhfykxy4p1uv6o.PNG" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the &lt;strong&gt;src&lt;/strong&gt; attribute takes in the audio source.&lt;/p&gt;

&lt;p&gt;And the type attribute gives more information about the type of the audio file. So if the audio was an MP3 file for example, we would have added &lt;strong&gt;type=audio/mpeg&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;type&lt;/strong&gt; attribute changes according to the type of the file formats&lt;/p&gt;

&lt;p&gt;Now if you refresh the browser you will not see anything, and that is because to display the audio elements we need to add the controls.&lt;/p&gt;

&lt;p&gt;So to add audio controls we’ll use the &lt;strong&gt;controls&lt;/strong&gt; attribute.&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%2Fa7pchaiutia8tznxvpq2.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%2Fa7pchaiutia8tznxvpq2.PNG" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can see the audio file add to the browser:&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%2Fcf1nuilzqok7rbdsx6ur.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%2Fcf1nuilzqok7rbdsx6ur.PNG" alt=" " width="303" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As for &lt;code&gt;&amp;lt;video&amp;gt;&amp;lt;/video&amp;gt;&lt;/code&gt; tag, we can use the same attributes to have more control over the audio file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- muted&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To play the audio without any sound the attribute muted should be added like this:&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%2Fgageqt7pjnt6v09ynuad.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%2Fgageqt7pjnt6v09ynuad.PNG" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you refresh the browser and play the audio, you will notice that the sound is now muted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- autoplay&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Audio autoplay attribute makes the audio play automatically when the page is displayed. However if you use Chrome, you will not be able to get the audio displayed automatically even if it is muted, and that is because Chrome has forbidden this.&lt;/p&gt;

&lt;p&gt;But, if you try with Firefox, you will see that the audio can be played automatically if it is muted.&lt;/p&gt;

&lt;p&gt;So the code is:&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%2Fn27giz9op164jfdlnbxx.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%2Fn27giz9op164jfdlnbxx.PNG" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the muted autoplay audio works well in Firefox.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)- loop&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To play the audio again and again in a loop you can add the loop attribute.&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%2F5kwub8ecfoo358gkvm8y.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%2F5kwub8ecfoo358gkvm8y.PNG" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can refresh the browser and see that the audio will be played again and again in a loop.&lt;/p&gt;

&lt;p&gt;That makes the audio playback easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- YouTube video
&lt;/h2&gt;

&lt;p&gt;Sometimes instead of adding a video directly to the web page, it would be better if we upload it to YouTube first and then add the link to the video to the web page. This will help avoid slowing down the loading of the web page and giving the user a bad experience.&lt;/p&gt;

&lt;p&gt;So to insert a YouTube video all we have to do is to use the &lt;code&gt;&amp;lt;iframe&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt; tag.&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%2Fi0dezy4pppaxqjxoz97p.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%2Fi0dezy4pppaxqjxoz97p.PNG" alt=" " width="800" height="379"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;strong&gt;src&lt;/strong&gt; attribute accepts the link to the YouTube video we want to add to our website.&lt;/p&gt;

&lt;p&gt;However, if you notice, the link of the YouTube video is not a “&lt;strong&gt;watch&lt;/strong&gt;” link, but it is an “&lt;strong&gt;embed&lt;/strong&gt;” link. Because inside the link there is this “&lt;strong&gt;/embed/&lt;/strong&gt;” keyword.&lt;/p&gt;

&lt;p&gt;So where can we find this “&lt;strong&gt;embed&lt;/strong&gt;” link?&lt;/p&gt;

&lt;p&gt;Simply by going to the YouTube video of your choice and click on the &lt;strong&gt;Share&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;When you click on the &lt;strong&gt;share&lt;/strong&gt; button you will have this box of choices you can choose from, either you can share the video via WhatsApp or Facebook or Twitter…But you will also have at the beginning the “&lt;strong&gt;Embed&lt;/strong&gt;” button like below:&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%2Fjxd6w47xz0tk7fb8ccvu.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%2Fjxd6w47xz0tk7fb8ccvu.PNG" alt=" " width="662" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now if you click on the “&lt;strong&gt;Embed&lt;/strong&gt;” button you will have this window:&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%2Fh765zlv5fobk028s8sh8.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%2Fh765zlv5fobk028s8sh8.PNG" alt=" " width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now you will see on the right the &lt;code&gt;&amp;lt;iframe&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt; tag we’re learning about in this tutorial.&lt;/p&gt;

&lt;p&gt;This is how YouTube inserts the videos and this is exactly what we will do.&lt;/p&gt;

&lt;p&gt;So if you want you can either copy/paste the &lt;code&gt;&amp;lt;iframe&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt; tag as it is to your code editor and you’re ready to go.&lt;/p&gt;

&lt;p&gt;Or if you don’t want all the attributes that are inside the &amp;lt;&lt;code&gt;iframe&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt; tag then you can just copy the “&lt;strong&gt;embed&lt;/strong&gt;” link as below and paste it to your code editor:&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%2Fswyk2zukdfld2r71ah57.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%2Fswyk2zukdfld2r71ah57.PNG" alt=" " width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in the browser we have:&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%2Fry3tdsu1zzqvofcegwo8.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%2Fry3tdsu1zzqvofcegwo8.PNG" alt=" " width="316" height="227"&gt;&lt;/a&gt;&lt;br&gt;
You can of course adjust the width and the height of the video either by adding the width and height attributes inside the &lt;code&gt;&amp;lt;iframe&amp;gt;&amp;lt;/iframe&amp;gt;&lt;/code&gt; tag, But the best practice is to keep HTML separated from CSS, so we will do that through CSS:&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%2Fuf2o0zbj7lqnlqgr5ixx.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%2Fuf2o0zbj7lqnlqgr5ixx.PNG" alt=" " width="800" height="134"&gt;&lt;/a&gt;&lt;br&gt;
So now we have a bigger video on the screen:&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%2Fglbv53bjjw0up8iquibv.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%2Fglbv53bjjw0up8iquibv.PNG" alt=" " width="574" height="456"&gt;&lt;/a&gt;&lt;br&gt;
Let’s see some attributes that we can use to have more control over the video.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- allowfullscreen&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To display the video full screen there is an attribute for that, and that is &lt;strong&gt;allowfullscreen&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If we add the “&lt;strong&gt;embed&lt;/strong&gt;” link only without this attribute then this feature below will be disabled.&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%2Fltexb63w1e9bruh53b1r.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%2Fltexb63w1e9bruh53b1r.PNG" alt=" " width="800" height="601"&gt;&lt;/a&gt;&lt;br&gt;
But if we add the &lt;strong&gt;allowfullscreen&lt;/strong&gt; attribute then the feature will be enabled.&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%2F4tx4nr25m2fi52fe0ily.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%2F4tx4nr25m2fi52fe0ily.PNG" alt=" " width="800" height="380"&gt;&lt;/a&gt;&lt;br&gt;
Now if we refresh we’ll have:&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%2Fs1r5kt0q4mgjf3uepwan.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%2Fs1r5kt0q4mgjf3uepwan.PNG" alt=" " width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the full screen video Mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- mute&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To make the video muted we’ll use the &lt;strong&gt;mute&lt;/strong&gt; attribute.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;mute&lt;/strong&gt; attribute is added inside the link, and it is given a value of 1.&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%2Fs7nsjgbc12vjus4cw91u.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%2Fs7nsjgbc12vjus4cw91u.PNG" alt=" " width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you refresh the browser and play the video, you will see that the sound is muted now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)- autoplay&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To play the video automatically it should be muted first.&lt;/p&gt;

&lt;p&gt;The attribute that will help us to play the video automatically is &lt;strong&gt;autoplay&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This attribute will also be added to the link and given a value of 1.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;mute&lt;/strong&gt; and &lt;strong&gt;autoplay&lt;/strong&gt; attributes will be separated by an ampersand “&amp;amp;”.&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%2Fa7w8qgbm28c6i9wa54at.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%2Fa7w8qgbm28c6i9wa54at.PNG" alt=" " width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if you refresh the browser, the video will start playing with a muted sound.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d)- loop&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to play the video over and over again, then &lt;strong&gt;loop&lt;/strong&gt; attribute will help you do that.&lt;/p&gt;

&lt;p&gt;However, this attribute will not be added directly after the link like &lt;strong&gt;mute&lt;/strong&gt; and &lt;strong&gt;autoplay&lt;/strong&gt; attributes.&lt;/p&gt;

&lt;p&gt;The syntax will be:&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%2Fnosil17cawqqjatqcmeg.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%2Fnosil17cawqqjatqcmeg.PNG" alt=" " width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you notice, we added the “&lt;strong&gt;playlist&lt;/strong&gt;” keyword first and we set the value of this keyword to the exact string value that comes after “&lt;strong&gt;embed/&lt;/strong&gt;“, and then we added an ampersand “&amp;amp;” and the &lt;strong&gt;loop&lt;/strong&gt; attribute.&lt;/p&gt;

&lt;p&gt;You can refresh the browser and see that the video will be played in a loop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e)- controls&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To display the video without any &lt;strong&gt;controls&lt;/strong&gt; you can use the controls attribute and set the value to 0.&lt;/p&gt;

&lt;p&gt;The default value of the &lt;strong&gt;controls&lt;/strong&gt; attribute is 1.&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%2Fj87raay31fdqw8068qd6.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%2Fj87raay31fdqw8068qd6.PNG" alt=" " width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4)- Conclusion
&lt;/h2&gt;

&lt;p&gt;Adding sound files and videos to the web page enhances the user experience.&lt;/p&gt;

&lt;p&gt;In this tutorial we’ve seen how to add these media to a website using different tags and default controls and attributes to have more control over the elements.&lt;/p&gt;

&lt;p&gt;We can add different audio formats and sound content to the website using audio tags.&lt;/p&gt;

&lt;p&gt;We can add a video directly to the website or through YouTube as well as some features using the video elements attributes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/tables-in-html/" rel="noopener noreferrer"&gt;tables in HTML&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-make-a-dropdown-list-in-html/" rel="noopener noreferrer"&gt;How to make a dropdown list in HTML?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/make-forms-with-html/" rel="noopener noreferrer"&gt;Make forms with HTML&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-make-a-navigation-bar/" rel="noopener noreferrer"&gt;How to make a navigation bar?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/html-lists/" rel="noopener noreferrer"&gt;HTML ordered and unordered lists&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Project: Digital Clock</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Tue, 22 Nov 2022 20:22:37 +0000</pubDate>
      <link>https://forem.com/salmittastyle/project-digital-clock-2291</link>
      <guid>https://forem.com/salmittastyle/project-digital-clock-2291</guid>
      <description>&lt;p&gt;In this project we will see how to create a digital clock like below:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/NXDiqkUkpKA"&gt;
&lt;/iframe&gt;
&lt;br&gt;
As you can see, the clock is not a static clock that shows the current time and stops, but it is a dynamic clock that keeps ticking just like your watch.&lt;/p&gt;

&lt;p&gt;We’ll use a little bit of HTML, CSS, and JavaScript.&lt;/p&gt;

&lt;p&gt;So let’s see how to accomplish this project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1: HTML
&lt;/h2&gt;

&lt;p&gt;To start this project we’re going to create a &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; that will contain all our elements and we will give it a class of container.&lt;/p&gt;

&lt;p&gt;So the HTML code will be:&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%2F4mrj1h3tf9b1zr7wsupy.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%2F4mrj1h3tf9b1zr7wsupy.PNG" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, we will create 3 &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; tags inside the &lt;strong&gt;container&lt;/strong&gt; &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let’s give the first &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; a class name of &lt;strong&gt;title&lt;/strong&gt;, and put inside it an &lt;code&gt;&amp;lt;h1&amp;gt;&amp;lt;/h1&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Let’s give the second &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; a class name of &lt;strong&gt;date&lt;/strong&gt; and add inside it a date just that you can see for the moment what it looks like.&lt;/p&gt;

&lt;p&gt;And let’s give the third &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; a class name of time and add inside it a time.&lt;/p&gt;

&lt;p&gt;So the final HTML code is:&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%2F3feb7ccg4yfjuuojzo4k.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%2F3feb7ccg4yfjuuojzo4k.PNG" alt=" " width="800" height="504"&gt;&lt;/a&gt;&lt;br&gt;
In the browser you’ll have:&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%2Fccr1fd8nnjl30io2qxcc.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%2Fccr1fd8nnjl30io2qxcc.PNG" alt=" " width="311" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: CSS
&lt;/h2&gt;

&lt;p&gt;Now let’s add some CSS.&lt;/p&gt;

&lt;p&gt;All our elements are inside the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; that has a class name of &lt;strong&gt;container&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So let’s start by centering vertically the elements inside the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To do that first of all we should give the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; a height. Here we’ll give it a height of 400px and the elements will be arranged inside this height of 400px.&lt;/p&gt;

&lt;p&gt;So to arrange and center the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; elements we will change the display property to flex, and add &lt;strong&gt;justify-content&lt;/strong&gt; and &lt;strong&gt;align-center&lt;/strong&gt; properties.&lt;/p&gt;

&lt;p&gt;As a background, we want an image. So we’ll use &lt;strong&gt;background-image&lt;/strong&gt; property to add the image. And as we want the image to be centered and we don’t want it to be repeated, we’ll add &lt;strong&gt;background-repeat&lt;/strong&gt; and &lt;strong&gt;background-position&lt;/strong&gt; properties.&lt;/p&gt;

&lt;p&gt;We’ll add also &lt;strong&gt;background-size&lt;/strong&gt; to resize the image.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2Fzphtawb6jcsrnh0a5eqe.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%2Fzphtawb6jcsrnh0a5eqe.PNG" alt=" " width="800" height="348"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fy83ac72p2y4qw9h4yo5o.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%2Fy83ac72p2y4qw9h4yo5o.PNG" alt=" " width="800" height="399"&gt;&lt;/a&gt;&lt;br&gt;
However, we want the elements to be one under another, not one next to another.&lt;/p&gt;

&lt;p&gt;As we added the display property and we set it to &lt;strong&gt;flex&lt;/strong&gt;, we can determine the main line for the elements.&lt;/p&gt;

&lt;p&gt;The main line simply means the line that will contain the elements. The line is either horizontal or vertical.&lt;/p&gt;

&lt;p&gt;So as we want the elements to be in a vertical line and not a horizontal one, we’ll add the &lt;strong&gt;flex-direction&lt;/strong&gt; property and set it to column.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2F5j1ssrz58fguch105rcj.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%2F5j1ssrz58fguch105rcj.PNG" alt=" " width="800" height="403"&gt;&lt;/a&gt;&lt;br&gt;
And then in the browser this will look like this:&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%2Fchb44rbuylkzlqvsprni.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%2Fchb44rbuylkzlqvsprni.PNG" alt=" " width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you noticed, we also added the position property, and that is because we will position the rest of the elements, but we need a reference to which we will position them. And this reference in the container &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To understand more CSS position and relative and absolute positions check this tutorial: &lt;a href="https://purpose-code.com/absolute-and-relative-positions-whats-the-difference/" rel="noopener noreferrer"&gt;absolute and relative positions: What’s the difference?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So let’s add some styling to the rest of elements and position them.&lt;/p&gt;

&lt;p&gt;For the second &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; that has a class name of title we will add a background color and center the text in the middle of the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We will also set a width and change the color of the text to white and add a bottom space.&lt;/p&gt;

&lt;p&gt;So the code is:&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%2Fbp45ubemsl66s4mjhfsf.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%2Fbp45ubemsl66s4mjhfsf.PNG" alt=" " width="800" height="615"&gt;&lt;/a&gt;&lt;br&gt;
In the browser it looks like:&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%2Frud5d7yxruvh6pq153xv.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%2Frud5d7yxruvh6pq153xv.PNG" alt=" " width="683" height="378"&gt;&lt;/a&gt;&lt;br&gt;
Let’s style now the 2 remaining &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;

&lt;p&gt;We’ll add a background color for each, center the text in the middle, add some padding and set a width and a position.&lt;/p&gt;

&lt;p&gt;So the CSS code will be at the end:&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%2Fn2s6xzlmlw1g66ldk9xq.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%2Fn2s6xzlmlw1g66ldk9xq.PNG" alt=" " width="598" height="848"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser that will be:&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%2Fywn8pr395ej2z7hnoy44.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%2Fywn8pr395ej2z7hnoy44.PNG" alt=" " width="736" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- Part 3: JavaScript
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;a)- Setting the date&lt;/strong&gt;&lt;br&gt;
First, let’s display the current day in the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; that has a class name of date.&lt;/p&gt;

&lt;p&gt;To do that we will work with the &lt;strong&gt;Date()&lt;/strong&gt; object and its methods.&lt;/p&gt;

&lt;p&gt;The code will be:&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%2Foq3jznd9opcesoizu96x.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%2Foq3jznd9opcesoizu96x.PNG" alt=" " width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s explain the code.&lt;/p&gt;

&lt;p&gt;First we selected the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; with the class name of &lt;strong&gt;date&lt;/strong&gt; because we’re going to need it later and we stored it inside the variable &lt;strong&gt;dateDiv&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Then we created a Date object using the &lt;strong&gt;new Date()&lt;/strong&gt; constructor that contains different methods to get the day, the month, the year…&lt;/p&gt;

&lt;p&gt;Inside the function &lt;strong&gt;displayDate()&lt;/strong&gt; we extracted the day, the month, the year and the date using the different methods &lt;strong&gt;getDay()&lt;/strong&gt;, &lt;strong&gt;getMonth()&lt;/strong&gt;, &lt;strong&gt;getFullYear()&lt;/strong&gt;, &lt;strong&gt;getDate()&lt;/strong&gt;. The values are stored in the variables &lt;strong&gt;day&lt;/strong&gt;, &lt;strong&gt;month&lt;/strong&gt;, &lt;strong&gt;year&lt;/strong&gt; and &lt;strong&gt;dayNumber&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As the &lt;strong&gt;getDay()&lt;/strong&gt; method returns a number from 0 to 6, with 0 being Sunday and 6 being Saturday, we added an array of weekDay where we stored the days of the week. this way if for example &lt;strong&gt;today.getDay()&lt;/strong&gt; returns 2, then &lt;strong&gt;weekday[2]&lt;/strong&gt; is Tuesday, which means &lt;strong&gt;weekday[day]&lt;/strong&gt; is Tuesday.&lt;/p&gt;

&lt;p&gt;Same thing for the months, the method &lt;strong&gt;getMonth()&lt;/strong&gt; returns a number from 0 to 11, with 0 being the month of January, and 11 being the month of December. That’s why we also created an array of all the months of the year.&lt;/p&gt;

&lt;p&gt;Finally we return the value of &lt;strong&gt;weekDay&lt;/strong&gt;, &lt;strong&gt;dayNumber&lt;/strong&gt;, &lt;strong&gt;yearMonths&lt;/strong&gt; and &lt;strong&gt;year&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At the end we just put the value that the function returns inside the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; we stored inside the variable &lt;strong&gt;dateDiv&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- Setting the time&lt;/strong&gt;&lt;br&gt;
Now, let’s display the current time in the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; that has a class name of time.&lt;/p&gt;

&lt;p&gt;So the code is:&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%2Fvhs8jsxq6qzg1ft20qw0.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%2Fvhs8jsxq6qzg1ft20qw0.PNG" alt=" " width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s explain the code.&lt;/p&gt;

&lt;p&gt;First we selected the &lt;code&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; with a class name of &lt;strong&gt;time&lt;/strong&gt; and stored it in variable that we named &lt;strong&gt;timeDiv&lt;/strong&gt; because we will use it later.&lt;/p&gt;

&lt;p&gt;Then we created a function &lt;strong&gt;displayTime()&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Inside this function we created another object using the &lt;strong&gt;new Date()&lt;/strong&gt; constructor once again.&lt;/p&gt;

&lt;p&gt;Then we extracted the hours, minutes and seconds using the &lt;strong&gt;getHours()&lt;/strong&gt;, &lt;strong&gt;getMinutes()&lt;/strong&gt; and &lt;strong&gt;getSeconds()&lt;/strong&gt; methods and we stored them in &lt;strong&gt;h&lt;/strong&gt;, &lt;strong&gt;m&lt;/strong&gt; and &lt;strong&gt;s&lt;/strong&gt; variables.&lt;/p&gt;

&lt;p&gt;After that we set the variable &lt;strong&gt;t&lt;/strong&gt; to “&lt;strong&gt;AM&lt;/strong&gt;” so that we can change between “&lt;strong&gt;AM&lt;/strong&gt;” and “&lt;strong&gt;PM&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;We added a condition to make the clock a 12 hour clock, because the &lt;strong&gt;getHours()&lt;/strong&gt; method returns a number from 0 to 23, but if we want a 12 hour clock we have to subtract 12 from 24 as we have 24 hours in a day.&lt;/p&gt;

&lt;p&gt;At the same time we said if the hours are greater than 12, which will then be the afternoon, then instead of “&lt;strong&gt;AM&lt;/strong&gt;” it should be “&lt;strong&gt;PM&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;Finally, we added the zero in front of the the hours the hours, minutes and seconds if they are less than 10, because the time will be normally displayed like this: 8: 6: 5 AM. So if we want it to be displayed like this instead 08: 06: 05 AM, we have to add a condition and say if the number is less than 10 then add a zero if not then keep the time as is. And this condition we added it using the ternary operator to make the code cleaner.&lt;/p&gt;

&lt;p&gt;At the end we added the &lt;strong&gt;setInterval&lt;/strong&gt; to repeat the function &lt;br&gt;
very 1000 ms to see it incrementing.&lt;/p&gt;

&lt;p&gt;The final JavaScript code is:&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%2Fr8mrzx3q4bra0w2mv18o.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%2Fr8mrzx3q4bra0w2mv18o.PNG" alt=" " width="800" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;Project: &lt;a href="https://purpose-code.com/project-password-generator/" rel="noopener noreferrer"&gt;Password Generator&lt;/a&gt;&lt;br&gt;
Project: &lt;a href="https://purpose-code.com/how-to-make-a-simple-piano-with-your-computer-keyboard/" rel="noopener noreferrer"&gt;How to make piano sounds with computer keyboard&lt;/a&gt;&lt;br&gt;
&lt;a href="https://purpose-code.com/how-to-make-money-as-a-web-developer7-income-sources/" rel="noopener noreferrer"&gt;How to make money as a web developer(7 sources of income)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://purpose-code.com/how-to-start-coding-the-ultimate-guide-for-beginners/" rel="noopener noreferrer"&gt;How to Start Coding in HTML, CSS, and JS: The Ultimate Guide for Beginners&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>How to Start Coding in HTML, CSS, and JS: The Ultimate Guide for Beginners</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sat, 19 Nov 2022 20:06:33 +0000</pubDate>
      <link>https://forem.com/salmittastyle/how-to-start-coding-in-html-css-and-js-the-ultimate-guide-for-beginners-4gij</link>
      <guid>https://forem.com/salmittastyle/how-to-start-coding-in-html-css-and-js-the-ultimate-guide-for-beginners-4gij</guid>
      <description>&lt;p&gt;Coding is the language of computers. It allows us to create programs that automate tasks, such as sending emails, creating spreadsheets, or even playing games. The good thing about coding is that anyone can learn it.&lt;/p&gt;

&lt;p&gt;Learning to code is a great way to get started in the tech field. There are plenty of resources out there to teach you how to program and become a web developer. In addition, there are also numerous opportunities for those who already have experience in web development to earn extra income through freelance projects.&lt;/p&gt;

&lt;p&gt;Learning programming requires patience and practice. There are no shortcuts. The good news is that once you get started, you'll see immediate benefits.&lt;/p&gt;

&lt;p&gt;In this article, we'll see the different steps that you should follow to get into web development and develop your coding skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)- Make a decision
&lt;/h2&gt;

&lt;p&gt;The first step to do before starting anything is to make a decision.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3OjjLAg" rel="noopener noreferrer"&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%2Fn1qoh21xhg8thnj2ms6c.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;br&gt;
Programming is very difficult. It takes time to grasp even the basic concepts of the programming language which is Javascript.&lt;/p&gt;

&lt;p&gt;And when I say that, I’m not talking about someone who wants only to take a look at the lines of codes to have a general idea of what programming looks like and move forward. When I say that programming takes time I’m talking about mastery, about someone who wants to master the game and create beautiful and meaningful things from what they learned to serve people.&lt;/p&gt;

&lt;p&gt;Before jumping into programming, and specifically web development, ask yourself if this is really what you want to learn. Ask yourself if you’re doing it because you really love it or if you’re doing it just for the sake of earning money because you heard jobs in web development pay very well. Or maybe you’re doing it just to show off because you heard that all people who are into programming are some kind of “geniuses“?&lt;/p&gt;

&lt;p&gt;Because you will face a lot of challenges down the road. There will be moments when you’ll write the code and it will not work, and you will not even understand why or what. There will be nobody there to help except your best friend “Google“, and even by looking in “Google” sometimes you will not find the answer to your problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3ElgdsH" rel="noopener noreferrer"&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%2Fxqbucecrim6decval3db.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Programming is a lonely road, if you are serious about it and want to become successful it will require a lot of sacrifices, like any other area of life.&lt;/p&gt;

&lt;p&gt;For example as a sacrifice, you should cut off this “Going out” with your friends every single day and waste time.&lt;/p&gt;

&lt;p&gt;I’m sorry to break it down to you but if you are serious about programming, you should sit every day for a certain amount of time, 2 hours, or 3 hours or 4 hours, whatever you feel comfortable with, and work on your programming skills. Because if you don’t revise what you learned yesterday and use the programming language every day, especially in the beginning, you will quickly forget it.&lt;/p&gt;

&lt;p&gt;A programming language is like English, French, or Spanish…&lt;/p&gt;

&lt;p&gt;Imagine you’re learning Spanish, you start the first day, and then on the second and third and fourth day you did not revise anything, and you expect to remember everything the fifth day and be successful, isn’t this the pure definition of insanity?&lt;/p&gt;

&lt;p&gt;So if you’re planning to go out with your friends every day and waste time, that you don’t have enough of by the way but you prefer to waste it anyway, then programming might not be for you. You should be able to say “No” when you’re friends invite you to go somewhere because your friends don’t have the same expectations as you. Your friends don’t dream big and are not mature enough to understand that this time that’s going to be wasted is actually precious and should be invested in what would benefit you and your family in the future.&lt;/p&gt;

&lt;p&gt;I’m not saying don’t have a social life either, but most of your time should be spent in programming, that is if you’re serious about it of course.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3hXs4FM" rel="noopener noreferrer"&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%2Fzhsdf2xhuy6dg3am91j7.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s why I’m saying that programming is a lonely road because most of the time you will be lonely, in your room or office, typing lines and lines of code and trying to understand the language by yourself.&lt;/p&gt;

&lt;p&gt;With all this in mind, that’s why you have to make a decision first before you start coding. You should weigh what is really important for you and what sacrifices are required for success, and see if you’re ready to abide by the rules. Because if you start programming just for the sake of showing off for example, you will not last that long.&lt;/p&gt;

&lt;p&gt;If you don’t like programming and you’re doing it in spite of yourself, then this is the quickest way to failure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3V8IpWD" rel="noopener noreferrer"&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%2Fkbufee1cb5rc8rr6hcqh.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- Adopt the right state of mind
&lt;/h2&gt;

&lt;p&gt;Before jumping into programming I would like to talk about having the right state of mind first.&lt;/p&gt;

&lt;p&gt;A lot of blogs and websites and videos out there talk only about the technical part and the books and courses you should buy to become the best programmer of 2022, but they don’t really shed the light on the truth of becoming a programmer and what it really takes from A to Z.&lt;/p&gt;

&lt;p&gt;So one of the requirements of learning how to code is to have the right state of mind. And to achieve the right state of mind there are 2 keys: meditation and personal development.&lt;/p&gt;

&lt;p&gt;What do meditation and personal development have to have with programming?&lt;/p&gt;

&lt;p&gt;Most people when you ask them about meditation they will say it will help you relax and calm down. But what do relax and calm down mean exactly?&lt;/p&gt;

&lt;p&gt;Because there is more to meditation than just “relax” and “calm down”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3TMLDhn" rel="noopener noreferrer"&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%2F03rda8ijqiz5s881g9uk.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The scientific explanation of what meditation is and how it really helps the brain we can find it in personal development, specifically the neuroscience area of personal development.&lt;/p&gt;

&lt;p&gt;I will explain quickly the science behind that and how it relates to programming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3ENefmC" rel="noopener noreferrer"&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%2F0i9adsm95wyv7c2zkg4f.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The human brain has 5 types of waves that we call brain waves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Delta waves: When the brain has delta waves we say that the brain or the human being is in a delta state. Delta state is when the brain activity is very very slow. Generally, we are in a delta state when we are sleeping. Babies are always in the delta state that’s why they’re sleeping most of the time.&lt;/li&gt;
&lt;li&gt;Theta waves: Theta waves are a little bit quicker than delta waves. Theta state is this state just right before you fall asleep. Before you go to bed you start feeling tired first and you start yawning and your eyes feel a little bit heavier. So this is the Theta state. When we are in theta state we feel very relaxed and we have this inward focus, and this is the state for creativity.&lt;/li&gt;
&lt;li&gt;Alpha waves: Alpha waves are quicker than theta waves. When we are in alpha state we feel very relaxed and we have this passive attention, and this is the best state for learning. Because when you learn in this state, your brain becomes like a sponge, it absorbs whatever comes its way easily.&lt;/li&gt;
&lt;li&gt;Beta waves: Beta waves are quick. And the beta state is the state we’re in every single day, at the office, at home, outside, when driving… It is this state where we have heightened attention, for example when you are in a meeting, you have your eyes open, you’re active and you pay attention.&lt;/li&gt;
&lt;li&gt;Gamma waves: Gamma waves are the quickest. Scientists found something interesting about these waves. When we are in the gamma state, although the waves are very quick, this state of mind is where this super intelligence that everybody’s looking for happens. When you are in this state you process information real quick, you don’t struggle at all as everything becomes clear and everything makes sense. Gamma brain waves are associated with higher brain functions like cognition and memory and high levels of thought and focus.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3gidWqf" rel="noopener noreferrer"&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%2Fi13x2kj1m72oynq6pin1.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope the picture is clear now. Meditation will help you achieve any state of mind you want. With a little bit of training, you will be able to decide whether you want to be in alpha state or theta state, or gamma state…&lt;/p&gt;

&lt;p&gt;Meditation is very important, and having the right state of mind before starting your programming session is crucial.&lt;/p&gt;

&lt;p&gt;You cannot start programming when you are angry or sad or upset. You have to calm down first and be in the right state of mind, and then you can start coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3gmQNmD" rel="noopener noreferrer"&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%2F0uwtf079ds2tl3z9jo44.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Personally, I find that being between theta and alpha state is really very helpful. I always try to be between these 2 states when I know that I will be learning a new lesson or a new chapter.&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- Do some research
&lt;/h2&gt;

&lt;p&gt;Start coding or programming is something that you might be looking forward to doing ASAP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3Ojf6OS" rel="noopener noreferrer"&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%2Fmypew96qi7an6hxw0wci.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you first get this idea to start programming, you get so excited, and you feel this boost of motivation and energy and this sensation that you can take on the world.&lt;/p&gt;

&lt;p&gt;So you start with the intention that you will learn everything, and this is the mistake that most people, especially beginners do.&lt;/p&gt;

&lt;p&gt;If we take web development for example, web development is so wide.&lt;/p&gt;

&lt;p&gt;You can do a lot of things with HTML, CSS and JavaScript. That’s why you should do some research to see which area you would like to learn exactly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3GrlqC9" rel="noopener noreferrer"&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%2F0weiq6eavk14skjql8qh.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Would you like to make static websites? Because in this case you will not need to learn JavaScript. HTML and CSS are enough to make a static website. Or would you like to make dynamic websites? in which case you need to learn JavaScript as well.&lt;/p&gt;

&lt;p&gt;Or maybe you want to make apps, you want to be an app developer. Or perhaps you’re interested in machine learning and AI more than anything else, and in this case you should learn JavaScript and other libraries that will allow you to build artificial intelligence.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3USrO9L" rel="noopener noreferrer"&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%2Fdob83ra0jej5m47yho25.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you see, there are many areas in web development, and if you want to learn them all from the beginning, you will get overwhelmed.&lt;/p&gt;

&lt;p&gt;That’s why you should do some research first and narrow it down so that you can choose your first pick to start with and concentrate all your energy on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4)- Start small
&lt;/h2&gt;

&lt;p&gt;Many people when they start programming at the beginning they want immediately start making the next Facebook or the next Netflix or Instagram.&lt;/p&gt;

&lt;p&gt;The guaranteed way to failure is exactly this. Because when you start, you’re like a baby, you don’t know anything and you’re here to learn. So if you start putting these barriers and obstacles from the beginning in your way, and jump right into the big things like making the next Facebook whilst you’re still learning the basics of the programming language, then what are you expecting exactly?&lt;/p&gt;

&lt;p&gt;Imagine if we ask a baby to run or participate in a marathon. You get the idea right?&lt;/p&gt;

&lt;p&gt;Of course you can make the next Facebook and the next snapshot if you want. Although they seem complex, in reality nothing is complex.&lt;/p&gt;

&lt;p&gt;Because what is a definition of complex? What do we call a complex app, or complex website, or complex system in general?&lt;/p&gt;

&lt;p&gt;A complex system is just the add-up of simple systems. Same thing, a complex website is just the add-up of simple principles and methods.&lt;/p&gt;

&lt;p&gt;For example, let’s say you want to make a blog website. If you take a closer look at what a blog website is exactly, it is just the addition of some simple HTML pages, combined with the storage of data in the backend, combined with some routing so that the user can be directed to the correct URL and some styling to make the website attractive.&lt;/p&gt;

&lt;p&gt;But to build such a website, you have to learn the basics, and the basics are HTML, CSS, and JavaScript, and then add to it the API part of JavaScript, and then the database part, and then you’re done.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://amzn.to/3hPL3SF" rel="noopener noreferrer"&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%2F42aqea8w484h7ofkipdj.png" alt=" " width="600" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can achieve anything you want, and you can make any website or app you want, but you have to start small.&lt;/p&gt;

&lt;p&gt;You can start for example by making a static website that has one page, about for example a biography of a certain well-known person. Once you feel comfortable you can add to it a small function that will greet the user when they enter the website. And stop there.&lt;/p&gt;

&lt;p&gt;And once you feel comfortable you can add to it a small form to ask the user for their name, phone number and email, and so on until you build a completely functional beautiful page.&lt;/p&gt;

&lt;h2&gt;
  
  
  5)-Use internet resources
&lt;/h2&gt;

&lt;p&gt;There are a lot of free resources out there, especially in this day and age.&lt;/p&gt;

&lt;p&gt;Many websites and blogs like this one offer free tutorials and courses to get you started with web development and coding in general. You just have to choose your pick.&lt;/p&gt;

&lt;p&gt;From Freecodecamp to W3schools to Codecademy, there are a lot of choices. All these platforms explain the basics of many programming languages in a simple way.&lt;/p&gt;

&lt;p&gt;Also, there are many communities that can answer your questions like stack overflow and Quora. So if you ever get stuck, just type your question in Google search bar and chances are you will find an answer to your problem.&lt;/p&gt;

&lt;p&gt;You can also post your questions in these communities and people will respond to you.&lt;/p&gt;

&lt;p&gt;If you are not much of a reader, then Youtube videos might be the best for you. Videos are fun and engaging and Youtube platform is saturated with all programming educational videos, so you can pick any Youtube video and get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  6)- Use books and online courses
&lt;/h2&gt;

&lt;p&gt;Although there are a lot of free resourses to learn programming and web development, the truth is there is nothing better than books and online courses.&lt;/p&gt;

&lt;p&gt;A simple Internet search for “how to add a function with javascript” will provide you with many answers. You will find tens, hundreds of articles on different websites with a couple of thousands words each, a handful of bullet points and a “recipe for success”, guaranteed to help you achieve your goals. &lt;/p&gt;

&lt;p&gt;But that barely scratches the surface of what you should be learning about functions and the tricks and tips to master them and become a great programmer.&lt;/p&gt;

&lt;p&gt;A book about Javascript will contain not only hundreds of pages of valuable information, but this information will be structured in an easily understandable manner and with a lot more context, which will help you better understand the topic than a couple of bullet points.&lt;/p&gt;

&lt;p&gt;Also, books and online courses are made by experts and people who have many years of experience, people who understood the real problem that others face because they’ve worked with so many students, and they’re trying now to come up with a better solution and make the process easier for you.&lt;/p&gt;

&lt;p&gt;Also, what nobody tells you is that, valuable information, that will really help you to become a master, you will not find it for free on the internet. Unfortunately, this is how it works in real life. You can start of course with free videos and tutorials, but at a certain point, you should invest in yourself for a better futur.&lt;/p&gt;

&lt;h2&gt;
  
  
  7- Complete projects and exercices
&lt;/h2&gt;

&lt;p&gt;Once you go through your favorite resources and understand the basics and the lessons , the best way to consolidate the information is by completing some programming projects and exercises around the same topic you learned.&lt;/p&gt;

&lt;p&gt;Because unless you put what you learned into practice, the ideas won’t fully materialize in your mind. That’s where projects come in.&lt;/p&gt;

&lt;p&gt;Coding problems and puzzles help you develop your programming skills. They also provide an opportunity to practice solving challenging problems.&lt;/p&gt;

&lt;p&gt;There are many websites that offer a wide range of exercises you can choose from. And they suggest also their source code as a solution.&lt;/p&gt;

&lt;p&gt;So be consistent and do the exercises every day.&lt;/p&gt;

&lt;h2&gt;
  
  
  8- Conclusion
&lt;/h2&gt;

&lt;p&gt;Learning web development languages gives you the opportunity to create applications that run inside any browser. You can use JavaScript to build things like games, animations, and even entire websites!&lt;/p&gt;

&lt;p&gt;Before you begin learning JavaScript, you need to understand what the basics of computer science are. Computer science is the study of algorithms, data structures, and problem-solving techniques. To become a good programmer, you need to understand these fundamental concepts.&lt;/p&gt;

&lt;p&gt;Once you have learned enough about JavaScript to feel comfortable coding and understood the abstract-concepts, you should try building something yourself. If you want to build a website, you could use HTML, CSS, and JavaScript to create a simple page. Or if you wanted to build a game, you could use JavaScript to control the movement of objects on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-make-money-as-a-web-developer7-income-sources/" rel="noopener noreferrer"&gt;How to make money as a webd developer?&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Inline vs Inline-Block vs Block CSS properties</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Thu, 17 Nov 2022 23:42:01 +0000</pubDate>
      <link>https://forem.com/salmittastyle/inline-vs-inline-block-vs-block-css-properties-2o7b</link>
      <guid>https://forem.com/salmittastyle/inline-vs-inline-block-vs-block-css-properties-2o7b</guid>
      <description>&lt;p&gt;CSS has become one of the most important aspects of web design. Displaying elements in the web browser is one of the basics that every front-end programmer must know.&lt;/p&gt;

&lt;p&gt;There are 3 types of CSS display properties that characterize every HTML elements: &lt;strong&gt;inline&lt;/strong&gt;, &lt;strong&gt;block&lt;/strong&gt; and &lt;strong&gt;inline-block&lt;/strong&gt; properties. So which one to choose and why?&lt;/p&gt;

&lt;p&gt;This article explains the differences between these three methods and gives examples of each.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)-Block element
&lt;/h2&gt;

&lt;p&gt;A block element, as the name indicates, is an element that occupies all the block, or in other words, all the space.&lt;/p&gt;

&lt;p&gt;As a block element takes all the place, it does not accept any other element next to it.&lt;/p&gt;

&lt;p&gt;As an example is better than words, let’s take an example of a simple paragraph.&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%2Fuptgx3b5zq61p0ntml2o.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%2Fuptgx3b5zq61p0ntml2o.PNG" alt=" " width="800" height="358"&gt;&lt;/a&gt;&lt;br&gt;
So this is a simple paragraph that looks in the browser like this:&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%2F1b4trg9gsez5uzf3nmse.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%2F1b4trg9gsez5uzf3nmse.PNG" alt=" " width="800" height="75"&gt;&lt;/a&gt;&lt;br&gt;
Let’s see the behavior of a block element.&lt;/p&gt;

&lt;p&gt;To do that we have to access the development tool of the browser.&lt;/p&gt;

&lt;p&gt;So Right click on the mouse and go to the “Inspect” area, click on “Inspect” and once clicked the browser console will open.&lt;/p&gt;

&lt;p&gt;Once opened go to “Elements” instead of “Console”, and there you will see all your HTML code.&lt;/p&gt;

&lt;p&gt;Another way to open the development tool without right click is to click on ctrl + shift + i.&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%2Fgll2pkxaf0jt4wr0v24k.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%2Fgll2pkxaf0jt4wr0v24k.PNG" alt=" " width="778" height="481"&gt;&lt;/a&gt;&lt;br&gt;
Once in the “Elements” tab just go and hover over your paragraph. You will see the following results:&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%2Fm0jii2pmh8lbj16g5o9h.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%2Fm0jii2pmh8lbj16g5o9h.PNG" alt=" " width="800" height="373"&gt;&lt;/a&gt;&lt;br&gt;
What does all that mean?&lt;/p&gt;

&lt;p&gt;As you can see, after hovering over the paragraph in the development tool, on the browser we can clearly see that the paragraph is inside a blue space or rectangle, and this blue space is surrounded by an orange space.&lt;/p&gt;

&lt;p&gt;And what does this orange space mean?&lt;/p&gt;

&lt;p&gt;The orange space means the margin. It is the margin set between this paragraph and other HTML elements. And you can see the explanation of the orange space in the box on the right in the development tool. Just go to the right and scroll a little bit down:&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%2Fjop56hpd05p5keo8opl6.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%2Fjop56hpd05p5keo8opl6.PNG" alt=" " width="324" height="260"&gt;&lt;/a&gt;&lt;br&gt;
So the orange space means “margin”, the yellow “border”, and the green “padding”.&lt;/p&gt;

&lt;p&gt;And it is this orange space that makes an element a &lt;strong&gt;block element&lt;/strong&gt;. It is this orange space that does not let any other element to be in the same line as the paragraph, and the paragraph occupies all the block because of this orange space, because as you see, the orange space takes all the width of the page.&lt;/p&gt;

&lt;p&gt;Other way to view things, we can say that a &lt;strong&gt;block element&lt;/strong&gt; is arrogant and does not let anyone approach it. What a difficult guy ! 😤&lt;/p&gt;

&lt;p&gt;An element is a block element because by default the CSS property &lt;strong&gt;display&lt;/strong&gt; is set to &lt;strong&gt;block&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- Inline element
&lt;/h2&gt;

&lt;p&gt;On the other hand there is the inline element.&lt;/p&gt;

&lt;p&gt;Unlike block element, inline element is modest, and accepts other HTML elements to be next to it. 😀&lt;/p&gt;

&lt;p&gt;Let’s take an image as an 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%2Fkt8jiifjqv46mfh2ichp.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%2Fkt8jiifjqv46mfh2ichp.PNG" alt=" " width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So here I took a simple image and I resized it using the following CSS code because it is so big:&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%2Fwdi3ewh47yqtuhn59hz3.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%2Fwdi3ewh47yqtuhn59hz3.PNG" alt=" " width="800" height="185"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So at the end I have the following image:&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%2Fkaiznankbtfeguoli7tc.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%2Fkaiznankbtfeguoli7tc.PNG" alt=" " width="800" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now same thing, we’ll go to the development tool and open the “Elements” tab, and we will hover over the image HTML code.&lt;/p&gt;

&lt;p&gt;So in the browser we’ll have:&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%2Figgx7y942pmocabvl6t8.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%2Figgx7y942pmocabvl6t8.PNG" alt=" " width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you have probably noticed by now, when we hover over the image in the development tool, on the browser the image is inside a blue space, and there is no orange space that surrounds it.&lt;/p&gt;

&lt;p&gt;That’s why the image is an &lt;strong&gt;inline element&lt;/strong&gt;. Because it occupies only the space tailored to its width, and not the width of the entire page.&lt;/p&gt;

&lt;p&gt;In the absence of the orange space, the HTML element can accept other HTML elements to be next to it.&lt;/p&gt;

&lt;p&gt;So if we want for example to add another image next to the cat image we can. Let’s add another image:&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%2Frfx5dealsrw9njj9nsjx.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%2Frfx5dealsrw9njj9nsjx.PNG" alt=" " width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will resize the second image as well. So we’ll have:&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%2Fe308poxlbl1jlwv3kayh.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%2Fe308poxlbl1jlwv3kayh.PNG" alt=" " width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser we have:&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%2Fnn9epbptjjioqmnd9zxq.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%2Fnn9epbptjjioqmnd9zxq.PNG" alt=" " width="800" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the two images are side by side now.&lt;/p&gt;

&lt;p&gt;However if you try to add a paragraph next to the image it will not work, because as we said, the paragraph is a &lt;strong&gt;block element&lt;/strong&gt;, and a &lt;strong&gt;block element is arrogant&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So it will generate a return to a new line, and then the paragraph will be created in the new line.&lt;/p&gt;

&lt;p&gt;An element is an inline element because by default the CSS property &lt;strong&gt;display&lt;/strong&gt; is set to &lt;strong&gt;inline&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- Inline-block element
&lt;/h2&gt;

&lt;p&gt;Now let’s say that we want the 2 images and the paragraph to be in one line. How to do that?&lt;/p&gt;

&lt;p&gt;Well, here comes the CSS property &lt;strong&gt;inline-block&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let’s give the paragraph the property of &lt;strong&gt;inline-block&lt;/strong&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%2Finlhgyhv6q6nars5u3cl.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%2Finlhgyhv6q6nars5u3cl.PNG" alt=" " width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CSS part will be:&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%2Ffqgg6nv39kf0b20o6mx0.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%2Ffqgg6nv39kf0b20o6mx0.PNG" alt=" " width="800" height="266"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fvnmn26i6x096osn26i7x.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%2Fvnmn26i6x096osn26i7x.PNG" alt=" " width="800" height="308"&gt;&lt;/a&gt;&lt;br&gt;
So now we have the 3 elements aligned. But how does this work behind the scenes?&lt;/p&gt;

&lt;p&gt;Let’s go one more time to the development tool and open it.&lt;/p&gt;

&lt;p&gt;What is interesting is when you hover over the paragraph. You will see this:&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%2Fjqjo6fktjij0c7jjlug0.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%2Fjqjo6fktjij0c7jjlug0.PNG" alt=" " width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the orange space that is responsible for the paragraph being arrogant is reduced now with the &lt;strong&gt;inline-block&lt;/strong&gt; property. And once it is reduced it allows to the paragraph that was a block element before, taking all the space to itself, to share the space with other HTML elements and accept elements to be next to it.&lt;/p&gt;

&lt;p&gt;But why we chose &lt;strong&gt;inline-block&lt;/strong&gt; property? Why we did not just set the &lt;strong&gt;display&lt;/strong&gt; CSS property of the paragraph to &lt;strong&gt;inline&lt;/strong&gt; instead of &lt;strong&gt;inline-block&lt;/strong&gt;? Because it would have worked also and all the elements would have been aligned as well.&lt;/p&gt;

&lt;p&gt;To answer this question read the next paragraph.&lt;/p&gt;

&lt;h2&gt;
  
  
  4)- Difference between inline and inline-block
&lt;/h2&gt;

&lt;p&gt;Let’s take an example of a long paragraph.&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%2Fy2fnrx7xsgoqnagp0x18.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%2Fy2fnrx7xsgoqnagp0x18.PNG" alt=" " width="800" height="466"&gt;&lt;/a&gt;&lt;br&gt;
So in the browser that will look like this:&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%2F81ln47olreky37lgr782.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%2F81ln47olreky37lgr782.PNG" alt=" " width="800" height="46"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s set the display property to inline and add some left, right, top and bottom margins to the paragraph.&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%2Fev9ztdvtk9r3e36xd7so.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%2Fev9ztdvtk9r3e36xd7so.PNG" alt=" " width="800" height="200"&gt;&lt;/a&gt;&lt;br&gt;
So in the browser we have:&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%2Fz6ftn2fwp6nsuju23ljo.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%2Fz6ftn2fwp6nsuju23ljo.PNG" alt=" " width="800" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we added the &lt;strong&gt;inline&lt;/strong&gt; property the paragraph became an inline element.&lt;/p&gt;

&lt;p&gt;As you can see, an inline element does not respect the top and bottom margins, and in this particular case neither the left and right margins.&lt;/p&gt;

&lt;p&gt;Although the first line moved a little bit to the left, but still the other lines did not move at all, not to mention the space between the first line and the top of page. There is no space at all.&lt;/p&gt;

&lt;p&gt;whereas if we set the &lt;strong&gt;display&lt;/strong&gt; property of the paragraph to &lt;strong&gt;inline-block&lt;/strong&gt; we’ll have this result:&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%2Ftyd82k4oqtonxstf2i94.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%2Ftyd82k4oqtonxstf2i94.PNG" alt=" " width="800" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which is the result expected. All the margins are respected.&lt;/p&gt;

&lt;p&gt;Another difference is the &lt;strong&gt;width&lt;/strong&gt; and the &lt;strong&gt;height&lt;/strong&gt; properties.&lt;/p&gt;

&lt;p&gt;Let’s remove the &lt;strong&gt;margin&lt;/strong&gt; property and go back to our paragraph which has &lt;strong&gt;inline&lt;/strong&gt; as CSS property.&lt;/p&gt;

&lt;p&gt;So now if we want to set a &lt;strong&gt;width&lt;/strong&gt; and a &lt;strong&gt;height&lt;/strong&gt; to our paragraph we’ll add the following code:&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%2F4bfy0pcqjqn8cdkpdc73.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%2F4bfy0pcqjqn8cdkpdc73.PNG" alt=" " width="800" height="228"&gt;&lt;/a&gt;&lt;br&gt;
If you refresh the browser you’ll see nothing has changed.&lt;/p&gt;

&lt;p&gt;However, if we set the display property of the paragraph to &lt;strong&gt;inline-block&lt;/strong&gt; and we add a &lt;strong&gt;width&lt;/strong&gt; and a &lt;strong&gt;height&lt;/strong&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%2Fr3zgwp3le9bysdcgzy3n.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%2Fr3zgwp3le9bysdcgzy3n.PNG" alt=" " width="800" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the browser our paragraph will be:&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%2Folcu62c1wxfu0ufbw2yt.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%2Folcu62c1wxfu0ufbw2yt.PNG" alt=" " width="794" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what we can conclude is that with &lt;strong&gt;inline-block&lt;/strong&gt; property we can set a &lt;strong&gt;width&lt;/strong&gt; and a &lt;strong&gt;height&lt;/strong&gt; and &lt;strong&gt;margins&lt;/strong&gt;, and they all will be respected.&lt;/p&gt;

&lt;p&gt;But with &lt;strong&gt;inline&lt;/strong&gt; property, even if we set &lt;strong&gt;width&lt;/strong&gt; and &lt;strong&gt;height&lt;/strong&gt; and &lt;strong&gt;margin&lt;/strong&gt; properties, they are not respected.&lt;/p&gt;

&lt;p&gt;That’s why we use &lt;strong&gt;inline-block&lt;/strong&gt; over &lt;strong&gt;inline&lt;/strong&gt; property when we want to make all the elements aligned, to preserve the HTML element’s properties in case if we want to add &lt;strong&gt;width&lt;/strong&gt; or &lt;strong&gt;height&lt;/strong&gt; or &lt;strong&gt;margin&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So to make the the 2 images and the paragraph aligned, we will set &lt;strong&gt;display&lt;/strong&gt; property of all the elements to &lt;strong&gt;inline-block&lt;/strong&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%2F4cp0rcsttcjt5udpynmb.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%2F4cp0rcsttcjt5udpynmb.PNG" alt=" " width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5)- Conclusion
&lt;/h2&gt;

&lt;p&gt;To sum up there are 3 types of display properties for an HTML element:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;inline&lt;/li&gt;
&lt;li&gt;block&lt;/li&gt;
&lt;li&gt;inline-block
inline property does not respect the width, height or margin if they’re added, whilst inline-block and block properties do.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So best practice is to have inline-block elements in your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read More:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://purpose-code.com/how-to-add-css-animations-to-a-website/" rel="noopener noreferrer"&gt;How to add CSS animation to a website?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://purpose-code.com/absolute-and-relative-positions-whats-the-difference/" rel="noopener noreferrer"&gt;Absolute and relative positions: What's the difference?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://purpose-code.com/css-margin-and-padding-what-are-they-and-how-do-we-use-them/" rel="noopener noreferrer"&gt;CSS margin and padding: What are they and how do we use them?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://purpose-code.com/list-style-type-css/" rel="noopener noreferrer"&gt;List style type CSS&lt;/a&gt;&lt;br&gt;
&lt;a href="https://purpose-code.com/css-border-how-to-add-a-border-and-make-it-rounded/" rel="noopener noreferrer"&gt;CSS border: How to add a border and make it rounded?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Object constructor functions: How does a constructor in javascript work?</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Tue, 15 Nov 2022 22:05:15 +0000</pubDate>
      <link>https://forem.com/salmittastyle/object-constructor-functions-how-does-a-constructor-in-javascript-work-1b06</link>
      <guid>https://forem.com/salmittastyle/object-constructor-functions-how-does-a-constructor-in-javascript-work-1b06</guid>
      <description>&lt;p&gt;JavaScript object constructors allow us to build objects dynamically. They provide a convenient alternative to creating objects manually. They also provide a convenient way to initialize variables when creating objects.&lt;/p&gt;

&lt;p&gt;In this article we’ll see how to create an object using JavaScript object constructor method, we’ll see also when exactly we can use this method to create objects.&lt;/p&gt;

&lt;p&gt;To see the other methods to use to create an object check my tutorial: &lt;a href="https://purpose-code.com/understanding-javascript-objects-from-basic-concepts-to-practical-usage/" rel="noopener noreferrer"&gt;Understanding Javascript Objects&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)- How to create an object using JavaScript object constructor method?
&lt;/h2&gt;

&lt;p&gt;As in real life, an object has many properties.&lt;/p&gt;

&lt;p&gt;If we take as an example a car, a car have properties such as color, weight, number of seats, speed, mileage, year of construction….&lt;/p&gt;

&lt;p&gt;Same thing if we take a pen. A pen can have as properties color, price, ink….&lt;/p&gt;

&lt;p&gt;In short, you can look at the properties as the things that describe the object.&lt;/p&gt;

&lt;p&gt;On the other hand, there are methods.&lt;/p&gt;

&lt;p&gt;The methods is what the object can do.&lt;/p&gt;

&lt;p&gt;For example for the car, it can drive, it can stop, it can crash….&lt;/p&gt;

&lt;p&gt;Same thing for the pen, it can write, it can break, it can dry…&lt;/p&gt;

&lt;p&gt;So to create an object using the JavaScript constructor method the syntax will be:&lt;br&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%2Ffy41cup3yojnhy0oio4r.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%2Ffy41cup3yojnhy0oio4r.PNG" alt=" " width="800" height="387"&gt;&lt;/a&gt;&lt;br&gt;
Let’s see in details what all this code means.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- Part 1 of the code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first part of the code is this one:&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%2Fqroofmmu1zcg75ozunlp.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%2Fqroofmmu1zcg75ozunlp.PNG" alt=" " width="800" height="241"&gt;&lt;/a&gt;&lt;br&gt;
What is happening here is that we used the constructor object function to create a template for our objects.&lt;/p&gt;

&lt;p&gt;Let’s say that we want to create many objects. For example 10 companies.&lt;/p&gt;

&lt;p&gt;We know that all companies will have some properties in common. They will all have a name, they will all have employees, they will all have salaries, they will all have a cafeteria and so on….&lt;/p&gt;

&lt;p&gt;So instead of creating each company apart, we will create a general or original object that will serve as a template for these companies.&lt;/p&gt;

&lt;p&gt;This general object will have the common properties that all companies have. And this general object’s name is the &lt;strong&gt;constructor object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If we have to name the constructor object “&lt;strong&gt;Company&lt;/strong&gt;“, then the code will be:&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%2Frmrks2lfyd2y1ea4xvly.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%2Frmrks2lfyd2y1ea4xvly.PNG" alt=" " width="800" height="244"&gt;&lt;/a&gt;&lt;br&gt;
The “&lt;strong&gt;Company&lt;/strong&gt;” constructor object will take some arguments. It can take as many arguments as you want, there are no limits.&lt;/p&gt;

&lt;p&gt;But what do these arguments represent?&lt;/p&gt;

&lt;p&gt;The arguments represent the values that we’re going to associate to the properties of the “Company” constructor object.&lt;/p&gt;

&lt;p&gt;For example if the name is one of the company properties, then we’ll have to give a name to this company.&lt;/p&gt;

&lt;p&gt;Same thing for employees, if the company has employees, we’ll have to say how many employees the company has.&lt;/p&gt;

&lt;p&gt;As we don’t want the values to be static but dynamic, we will give a name to each value. So the constructor properties will be:&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%2Fq6cc5yva1ocw9r3c93cj.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%2Fq6cc5yva1ocw9r3c93cj.PNG" alt=" " width="800" height="244"&gt;&lt;/a&gt;&lt;br&gt;
Now it is time to give a name to our properties.&lt;/p&gt;

&lt;p&gt;We said that the company has a name, employeesNumber and cafeteriaNumber as properties. So we’ll name our properties this way. You can give the properties any name you want.&lt;/p&gt;

&lt;p&gt;The code becomes:&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%2Fd3xygbphjrxk1awsbmge.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%2Fd3xygbphjrxk1awsbmge.PNG" alt=" " width="800" height="244"&gt;&lt;/a&gt;&lt;br&gt;
So here we gave a name to our properties and associated the values to the properties at the same time.&lt;/p&gt;

&lt;p&gt;But wait, what does the keyword “&lt;strong&gt;this&lt;/strong&gt;” mean?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does the keyword “this” mean?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this particular case, and when used with objects, &lt;strong&gt;this&lt;/strong&gt; keyword refers to the object itself.&lt;/p&gt;

&lt;p&gt;In other words, and simply, instead of &lt;strong&gt;this.name&lt;/strong&gt; or &lt;strong&gt;this.employeesNumber&lt;/strong&gt; you can see it as &lt;strong&gt;Company.name&lt;/strong&gt; or &lt;strong&gt;Company.employeesNumber&lt;/strong&gt;, which reminds us of the object literal notation.&lt;/p&gt;

&lt;p&gt;So this replaces &lt;strong&gt;Company&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now that we got this out of the way there is one last thing about the function constructor object and that is the constructor object function can have methods.&lt;/p&gt;

&lt;p&gt;In other words, the &lt;strong&gt;object constructor function&lt;/strong&gt; can have some functions that it will execute. And these functions are called methods.&lt;/p&gt;

&lt;p&gt;Let’s go crazy and imagine that the &lt;strong&gt;Company&lt;/strong&gt; talks, and whenever it pays the employees it says: “Yay! I finally paid my 5 employees” or&lt;/p&gt;

&lt;p&gt;“Yay! I finally paid my 7 employees” or “Yay! I finally paid my 123 employees”, depending on the number of employees.&lt;/p&gt;

&lt;p&gt;Let’s name the method “pay”, so the code becomes:&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%2Fstw38uitf2hwtbhf9a4n.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%2Fstw38uitf2hwtbhf9a4n.PNG" alt=" " width="800" height="243"&gt;&lt;/a&gt;&lt;br&gt;
So here the name of the method is “&lt;strong&gt;pay&lt;/strong&gt;” and we declared it with an anonymous function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- Part 2 of the code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that our template is ready, it is time we create our 10 companies from it.&lt;/p&gt;

&lt;p&gt;We said that the properties our 10 companies have are those our template has.&lt;/p&gt;

&lt;p&gt;So to create a company, let’s call it “&lt;strong&gt;company1&lt;/strong&gt;“, the code will be:&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%2Flfwd6u9nbgi9wr6mi6hv.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%2Flfwd6u9nbgi9wr6mi6hv.PNG" alt=" " width="800" height="76"&gt;&lt;/a&gt;&lt;br&gt;
Wow, what happened here? How does this code work?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does the keyword “new” mean?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The keyword ‘&lt;strong&gt;new&lt;/strong&gt;‘ simply means that you want to instantiate (create) a new object. So when you write: &lt;strong&gt;new Company()&lt;/strong&gt; that simply means you want to create a new object using the “&lt;strong&gt;Company&lt;/strong&gt;” object constructor. Which means using the template “Company“. So you call the &lt;strong&gt;object constructor function&lt;/strong&gt; (as it is a function) using the keyword “&lt;strong&gt;new&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;Our object constructor “&lt;strong&gt;Company&lt;/strong&gt;” accepts 3 arguments: companyName, numberOfEmployees and numberOfCafeteria.&lt;/p&gt;

&lt;p&gt;So for the “&lt;strong&gt;company1&lt;/strong&gt;” to have its own properties we have to replace these arguments with the real values of the “company1“.&lt;/p&gt;

&lt;p&gt;Here “&lt;strong&gt;company1&lt;/strong&gt;” has a name of Google, and a number of employees of 150028 and a number of cafeterias of 800, so we replaced the arguments of the constructor object with these values.&lt;/p&gt;

&lt;p&gt;Behind the scenes this works as follow:&lt;/p&gt;

&lt;p&gt;As we called the function constructor object “&lt;strong&gt;Company&lt;/strong&gt;“, The arguments companyName, numberOfEmployees and numberOfCafeteria will be replaced with the values “Google”, “150028”, “800” like this:&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%2Famelriiuck0kv0ycllln.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%2Famelriiuck0kv0ycllln.PNG" alt=" " width="800" height="287"&gt;&lt;/a&gt;&lt;br&gt;
As these values are associated to the properties, the properties will be:&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%2F3s0ya4zna7dly14wvj9y.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%2F3s0ya4zna7dly14wvj9y.PNG" alt=" " width="800" height="240"&gt;&lt;/a&gt;&lt;br&gt;
That’s how the object “&lt;strong&gt;company1&lt;/strong&gt;” is created from the function object constructor “&lt;strong&gt;Company&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;Now if we want to create the remaining 9 companies all we have to do is to call the object constructor function “&lt;strong&gt;Company&lt;/strong&gt;” and pass it some values.&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%2Fusxo0p44fqk9cc1x00ea.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%2Fusxo0p44fqk9cc1x00ea.PNG" alt=" " width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- How to access objects properties and methods?
&lt;/h2&gt;

&lt;p&gt;To access an object property or an object method, it is very simple. All you have to do is to use the dot notation.&lt;/p&gt;

&lt;p&gt;Meaning the following syntax: &lt;strong&gt;objectName.property&lt;/strong&gt; or &lt;strong&gt;objectName.method()&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let’s say that we want to display the number of employees of IBM as well as the name of the company.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2Fn78hmfp129vz0vi9ngpq.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%2Fn78hmfp129vz0vi9ngpq.PNG" alt=" " width="800" height="547"&gt;&lt;/a&gt;&lt;br&gt;
In the browser console we’ll have:&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%2Fhfqru7sf3mjf0tcf63ra.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%2Fhfqru7sf3mjf0tcf63ra.PNG" alt=" " width="417" height="124"&gt;&lt;/a&gt;&lt;br&gt;
Now let’s say we want to access the method “pay”. The code will be:&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%2Fdr1lhfgj5ok6sfbu7jc5.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%2Fdr1lhfgj5ok6sfbu7jc5.PNG" alt=" " width="800" height="562"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we’ll have:&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%2Fmcswoo3ynqwcptb977a9.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%2Fmcswoo3ynqwcptb977a9.PNG" alt=" " width="473" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- How to add properties and methods to an object?
&lt;/h2&gt;

&lt;p&gt;Sometimes we want to add properties and methods to an object, that are specific to that particular object.&lt;/p&gt;

&lt;p&gt;Let’s say here that although we created common properties to all the companies, we want to add a property that is specific to Tesla company and that does not exist in other companies, which is the type of car.&lt;/p&gt;

&lt;p&gt;so to add a property to this company the code will be:&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%2Fwd9rcm2idrzazeddhkli.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%2Fwd9rcm2idrzazeddhkli.PNG" alt=" " width="800" height="583"&gt;&lt;/a&gt;&lt;br&gt;
We used the exact notation as when we wanted to access the properties, which means the dot notation.&lt;/p&gt;

&lt;p&gt;We added a property, its name is carType, and we gave it a value, which is Electrical cars.&lt;/p&gt;

&lt;p&gt;Now if we display this in the browser we’ll have:&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%2F7lbmzkudvo8qct95qqi4.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%2F7lbmzkudvo8qct95qqi4.PNG" alt=" " width="800" height="70"&gt;&lt;/a&gt;&lt;br&gt;
As you can see, carType has became now one of the company6 properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  4)- Conclusion
&lt;/h2&gt;

&lt;p&gt;Javascript has become very popular over the years because of its simplicity and ease of use. The language itself is quite simple and easy to master. However, sometimes it gets confusing when dealing with objects.&lt;/p&gt;

&lt;p&gt;In this tutorial we’ve seen what an object constructor is and how to create it. The constructor function is a special method that allows you to define properties and methods on a newly created object. In other words, it lets you customize the behavior of a particular object at runtime.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>What are the different types of inputs in HTML forms?</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Sun, 13 Nov 2022 16:13:25 +0000</pubDate>
      <link>https://forem.com/salmittastyle/what-are-the-different-types-of-inputs-in-html-forms-32gk</link>
      <guid>https://forem.com/salmittastyle/what-are-the-different-types-of-inputs-in-html-forms-32gk</guid>
      <description>&lt;p&gt;Form inputs are used to collect data from users. They include text boxes, checkboxes, radio buttons, file upload fields, password inputs, date pickers, and so much more. Learn how they work and what each element does.&lt;/p&gt;

&lt;p&gt;To know more how to create a form from scratch check my tutorial: &lt;a href="https://purpose-code.com/make-forms-with-html/" rel="noopener noreferrer"&gt;Make forms with HTML&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this article we’ll take a look at the different inputs that a form can have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Different Form inputs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;a)- input type text&lt;/strong&gt;&lt;br&gt;
The input type text defines a text input that the user should enter.&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%2Fekdfbnpfb9btb7ksa15m.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%2Fekdfbnpfb9btb7ksa15m.PNG" alt=" " width="800" height="115"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fbxugqbn6iomkso9qkn2x.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%2Fbxugqbn6iomkso9qkn2x.PNG" alt=" " width="343" height="62"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;b)- input type password&lt;/strong&gt;&lt;br&gt;
the input type password allows to the user to enter their password.&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%2Fw266yxqu3pr1jon86f7u.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%2Fw266yxqu3pr1jon86f7u.PNG" alt=" " width="800" height="115"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fyxbslqthhe2veng97lon.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%2Fyxbslqthhe2veng97lon.PNG" alt=" " width="373" height="105"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;c)- input type checkbox&lt;/strong&gt;&lt;br&gt;
input type checkbox creates checkboxes in case if there are multiple choices to offer to the user.&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%2Fw40rwcj8vqrn2a18cclb.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%2Fw40rwcj8vqrn2a18cclb.PNG" alt=" " width="800" height="138"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2F2rk14qr3pnsaujb1yr98.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%2F2rk14qr3pnsaujb1yr98.PNG" alt=" " width="353" height="195"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;d)- input type radio&lt;/strong&gt;&lt;br&gt;
Similar to input type checkbox, input type radio creates radio buttons in case if there are multiple choices to offer to the user.&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%2Frrv031shhj9acjvng73z.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%2Frrv031shhj9acjvng73z.PNG" alt=" " width="800" height="142"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fxcwodrin4h68fh79vd59.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%2Fxcwodrin4h68fh79vd59.PNG" alt=" " width="361" height="269"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;e)- input type email&lt;/strong&gt;&lt;br&gt;
input type email is used for input fields that should contain email. If the input containes other thing than an email the form will not be submitted.&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%2Fo47sjfddh9qcvy7pv6rp.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%2Fo47sjfddh9qcvy7pv6rp.PNG" alt=" " width="800" height="115"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2F757xcko98h80e97fcbx7.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%2F757xcko98h80e97fcbx7.PNG" alt=" " width="352" height="303"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;f)- input type file&lt;/strong&gt;&lt;br&gt;
input type file allows the user to upload documents and images.&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%2Fexxrqor2calbw4ronoil.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%2Fexxrqor2calbw4ronoil.PNG" alt=" " width="800" height="115"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2F56f91qdvai2jr1dkdvuj.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%2F56f91qdvai2jr1dkdvuj.PNG" alt=" " width="354" height="339"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;g)- input type color&lt;/strong&gt;&lt;br&gt;
input type color is used to choose a color.&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%2F8p7ymhhzmlyr7ndj44ay.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%2F8p7ymhhzmlyr7ndj44ay.PNG" alt=" " width="800" height="114"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Futlquv0a15dd9cxzl18a.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%2Futlquv0a15dd9cxzl18a.PNG" alt=" " width="357" height="395"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;h)- input type date&lt;/strong&gt;&lt;br&gt;
input type date is used toselect a date.&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%2Faku0pxynayy0aq9uxgpo.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%2Faku0pxynayy0aq9uxgpo.PNG" alt=" " width="800" height="115"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fafwbtnvpo4tjym2zz98j.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%2Fafwbtnvpo4tjym2zz98j.PNG" alt=" " width="356" height="440"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;i)- input type month&lt;/strong&gt;&lt;br&gt;
input type month allows the user to select a month and a year.&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%2Fhtjgt6aoy8jmjud4jv09.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%2Fhtjgt6aoy8jmjud4jv09.PNG" alt=" " width="800" height="117"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fqj8l1wz561blqjgpto53.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%2Fqj8l1wz561blqjgpto53.PNG" alt=" " width="354" height="487"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;j)- input type week&lt;/strong&gt;&lt;br&gt;
week input allows the user to select a week and a year.&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%2Fatbuovutqaw64d7mqqys.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%2Fatbuovutqaw64d7mqqys.PNG" alt=" " width="800" height="114"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Ff26ghcj5dd4ehu6favle.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%2Ff26ghcj5dd4ehu6favle.PNG" alt=" " width="349" height="536"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;k)- input type url&lt;/strong&gt;&lt;br&gt;
input type url is used to add a URL.&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%2Fx89fv9yoea5izr6ira7r.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%2Fx89fv9yoea5izr6ira7r.PNG" alt=" " width="800" height="118"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fioef03xjero4935jbux6.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%2Fioef03xjero4935jbux6.PNG" alt=" " width="350" height="572"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;l)- input type time&lt;/strong&gt;&lt;br&gt;
time input allows the user to choose a time, either AM or PM.&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%2F9ccbzzg727h6rw8j9ikj.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%2F9ccbzzg727h6rw8j9ikj.PNG" alt=" " width="800" height="116"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2F85voow5ial2i4lbe3s1u.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%2F85voow5ial2i4lbe3s1u.PNG" alt=" " width="361" height="620"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;m)- input type tel&lt;/strong&gt;&lt;br&gt;
input type tel is used to add a phone number.&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%2Fm8mqlvgeio48cbwvp1ex.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%2Fm8mqlvgeio48cbwvp1ex.PNG" alt=" " width="800" height="117"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Ffuolcwxua6920dlejcn0.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%2Ffuolcwxua6920dlejcn0.PNG" alt=" " width="356" height="657"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;n)- input type range&lt;/strong&gt;&lt;br&gt;
range input allows the user to choose a number between 0 and 100.&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%2Fss506a402h3t2le8o1ug.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%2Fss506a402h3t2le8o1ug.PNG" alt=" " width="800" height="115"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2F8mt8rweyec0ive5oyjny.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%2F8mt8rweyec0ive5oyjny.PNG" alt=" " width="364" height="698"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;o)- input type search&lt;/strong&gt;&lt;br&gt;
search input acts like a search bar.&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%2Fqf1h4lpiamyknltkimhc.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%2Fqf1h4lpiamyknltkimhc.PNG" alt=" " width="800" height="116"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have&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%2F5pzscts3jqcdcvgp32j5.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%2F5pzscts3jqcdcvgp32j5.PNG" alt=" " width="351" height="741"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;p)- input type reset&lt;/strong&gt;&lt;br&gt;
reset input will create a reset button that, when clicked, will refresh the form values. So no need to refresh the browser to reset the form values.&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%2F2w8xafzx8rh2z6aj21vd.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%2F2w8xafzx8rh2z6aj21vd.PNG" alt=" " width="800" height="117"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fnbe0p94jexo3p3nnf4dj.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%2Fnbe0p94jexo3p3nnf4dj.PNG" alt=" " width="352" height="790"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;q)- input type submit&lt;/strong&gt;&lt;br&gt;
A submit input will create a button that, when clicked, submits the form to the server.&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%2Fvdlucftljvabxayffjgk.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%2Fvdlucftljvabxayffjgk.PNG" alt=" " width="800" height="119"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fwiunp8oz1sn76pb9g430.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%2Fwiunp8oz1sn76pb9g430.PNG" alt=" " width="358" height="838"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;r)- input type image&lt;/strong&gt;&lt;br&gt;
image input creates an image as a submit button.&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%2Frps3nbngpo0z0jwf0dpy.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%2Frps3nbngpo0z0jwf0dpy.PNG" alt=" " width="800" height="118"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2F68hr3dtrcmd23fhc6d7u.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%2F68hr3dtrcmd23fhc6d7u.PNG" alt=" " width="355" height="899"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, forms allow users to submit information about themselves to websites. They’re also used by search engines to index sites and understand their structure.&lt;/p&gt;

&lt;p&gt;You should now know the different inputs that you can use with a Form.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Understanding JavaScript Objects: From Basic Concepts to Practical Usage</title>
      <dc:creator>Salma</dc:creator>
      <pubDate>Fri, 11 Nov 2022 12:23:32 +0000</pubDate>
      <link>https://forem.com/salmittastyle/understanding-javascript-objects-from-basic-concepts-to-practical-usage-3g0c</link>
      <guid>https://forem.com/salmittastyle/understanding-javascript-objects-from-basic-concepts-to-practical-usage-3g0c</guid>
      <description>&lt;h2&gt;
  
  
  1)- What is an object in JavaScript?
&lt;/h2&gt;

&lt;p&gt;In JavaScript, objects are a fundamental data structure that represent collections of data.&lt;/p&gt;

&lt;p&gt;In the real world, there are many objects that have many properties and behaviors like pen, pencil, car, knife, fork…. Same thing in JavaScript, objects have a number of properties and methods that allow them to be manipulated and queried.&lt;/p&gt;

&lt;p&gt;JavaScript objects can be created from any type of data, including arrays and strings.&lt;/p&gt;

&lt;h2&gt;
  
  
  2)- How do you create and use objects in JavaScript?
&lt;/h2&gt;

&lt;p&gt;In JavaScript, there are few ways to create objects. Let’s have a look at each one of them:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- Object Literal&lt;/strong&gt;&lt;br&gt;
Object literal is the simplest method used to declare and create a JavaScript object.&lt;/p&gt;

&lt;p&gt;Let’s say we want to create a Car object.&lt;/p&gt;

&lt;p&gt;As we know, the car has some properties. It has doors, color, brand, speed…&lt;/p&gt;

&lt;p&gt;So we will declare a Car object that has these properties like this:&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%2Fsm6r55kq8191m1tppt2i.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%2Fsm6r55kq8191m1tppt2i.PNG" alt=" " width="800" height="153"&gt;&lt;/a&gt;&lt;br&gt;
The “&lt;strong&gt;name&lt;/strong&gt;”, “&lt;strong&gt;numberOfDoors&lt;/strong&gt;” and “&lt;strong&gt;color&lt;/strong&gt;” are called properties.&lt;/p&gt;

&lt;p&gt;“&lt;strong&gt;BMW&lt;/strong&gt;”, “&lt;strong&gt;4&lt;/strong&gt;” and  “&lt;strong&gt;White&lt;/strong&gt;” are called the values of the properties.&lt;/p&gt;

&lt;p&gt;So in the object literal method we always define the properties and their values.&lt;/p&gt;

&lt;p&gt;We can also declare and create an empty object like this:&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%2Fo4o6g7k2j7is85vzpxq0.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%2Fo4o6g7k2j7is85vzpxq0.PNG" alt=" " width="800" height="57"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;b)- Using the new keyword&lt;/strong&gt;&lt;br&gt;
Another way to create a JavaScript object is to use the &lt;strong&gt;new&lt;/strong&gt; keyword with the constructor Object.&lt;/p&gt;

&lt;p&gt;The code will be:&lt;br&gt;
As you can see, an empty object does not contain any properties or values. We can add properties and values as indicated later on in this tutorial in section 3.&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%2Fue2atkgu0nnvx99lkimm.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%2Fue2atkgu0nnvx99lkimm.PNG" alt=" " width="800" height="59"&gt;&lt;/a&gt;&lt;br&gt;
By writing this code we have created an empty object.&lt;/p&gt;

&lt;p&gt;We will also see later on how to add properties to the object.&lt;br&gt;
&lt;strong&gt;c)- Using Object.create() method&lt;/strong&gt;&lt;br&gt;
This method of creating an object comes in very handy when we want to create an object from another existing object.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Object.create()&lt;/strong&gt; method takes 2 parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first parameter is a mandatory object. It is the one that we will create our object from.&lt;/li&gt;
&lt;li&gt;The second parameter is an optional object which contains the properties to be added to the new object.
Let’s say that we have a company, and the company name is “Purpose”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The company object will be:&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%2Fvp3xjxkeyui2avafnnzu.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%2Fvp3xjxkeyui2avafnnzu.PNG" alt=" " width="800" height="107"&gt;&lt;/a&gt;&lt;br&gt;
And we want to create an employee for this company. So th employee works at this company named “Purpose”. As he is an employee of the same company, instead of building another object from scratch that contains the company name and the employee name, age, years of experience… we will use the “company” object we created.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2F3xyek6ih6x90zaowfdzb.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%2F3xyek6ih6x90zaowfdzb.PNG" alt=" " width="800" height="306"&gt;&lt;/a&gt;&lt;br&gt;
So now as we created the “employee” object from the “company” object, that means the “employee” object will have access to all properties of the “company” object.&lt;/p&gt;

&lt;p&gt;In other words, if we want to know the name of the company of the employee, all we have to do is to access this name this way:&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%2Ft8ktelk02pscpsbrdi6i.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%2Ft8ktelk02pscpsbrdi6i.PNG" alt=" " width="800" height="56"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fy6z6ty7b4j51l194gwk9.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%2Fy6z6ty7b4j51l194gwk9.PNG" alt=" " width="377" height="148"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;d)- Object constructor function&lt;/strong&gt;&lt;br&gt;
Another way to create an object is to use the &lt;strong&gt;object constructor function&lt;/strong&gt; method.&lt;/p&gt;

&lt;p&gt;What is an &lt;strong&gt;object constructor function&lt;/strong&gt;? It is simply a simple function that gives the template of a parent object, or the original object that we will use to create our derivative objects.&lt;/p&gt;

&lt;p&gt;For example, let’s say that we want to create many houses objects.&lt;/p&gt;

&lt;p&gt;We have one house that has 4 bedrooms, 2 living room, 2 toilets ,1 yard and is located in Florida. Another house that has 3 bedrooms, one living room, 1 toilet, 1 yard and is located in Tokyo. Another house that has 6 bedrooms, 3 living rooms, 4 toilets , 2 yards and is located in London and so on…&lt;/p&gt;

&lt;p&gt;So instead of creating 3 separate objects for the 3 houses like this:&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%2Fl2b3b73md21ihsbngl6q.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%2Fl2b3b73md21ihsbngl6q.PNG" alt=" " width="800" height="576"&gt;&lt;/a&gt;&lt;br&gt;
What we can do is to create a common template for the houses. Because after all, they all have bedrooms, living rooms, toilets, yards and a location.&lt;/p&gt;

&lt;p&gt;So to create this template we will use the &lt;strong&gt;object constructor function&lt;/strong&gt; like this:&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%2F19iqxxv8gqpsgyskaiyb.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%2F19iqxxv8gqpsgyskaiyb.PNG" alt=" " width="800" height="120"&gt;&lt;/a&gt;&lt;br&gt;
Note here that the &lt;strong&gt;House&lt;/strong&gt; constructor starts with an upper-case “H”, and that is because we should always start a function constructor name with an upper-case.&lt;/p&gt;

&lt;p&gt;Once we create a function constructor object, we add all the properties inside the function.&lt;/p&gt;

&lt;p&gt;In the below section, we’ll see how to add and access JavaScript objects properties and methods. So stay tuned. 😉&lt;/p&gt;

&lt;p&gt;But for the moment, let’s suppose that we have all the properties inside the function, how can we create an object for every house?&lt;/p&gt;

&lt;p&gt;To create an object for every house all we have to do is to call the function constructor object using the keyword &lt;strong&gt;new&lt;/strong&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%2Fvx49oszlict07s0r5iql.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%2Fvx49oszlict07s0r5iql.PNG" alt=" " width="800" height="207"&gt;&lt;/a&gt;&lt;br&gt;
So here by calling the House function constructor, and by passing it the number of bedrooms, living rooms, toilets, yard, location we want for every house, we create an object for every house separately.&lt;/p&gt;

&lt;p&gt;The House constructor object is a function that takes in as parameters the values of the object properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  3)- What are the properties and methods of an object?
&lt;/h2&gt;

&lt;p&gt;You can look at the properties of an object as its description, and a method as an action or a function that the object can perform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a)- Object Literal&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1)- Properties&lt;/strong&gt;&lt;br&gt;
We’ve seen how to create an object with the Object literal method.&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%2F56qaq3fiee3fsrqphew2.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%2F56qaq3fiee3fsrqphew2.PNG" alt=" " width="800" height="153"&gt;&lt;/a&gt;&lt;br&gt;
and we said that for the “&lt;strong&gt;car&lt;/strong&gt;” object the “&lt;strong&gt;name&lt;/strong&gt;”, “&lt;strong&gt;numberOfDoors&lt;/strong&gt;” and “&lt;strong&gt;color&lt;/strong&gt;” are the object properties and “&lt;strong&gt;BMW&lt;/strong&gt;”, “&lt;strong&gt;4&lt;/strong&gt;” and  “&lt;strong&gt;White&lt;/strong&gt;” are the values of the&lt;br&gt;
properties.&lt;/p&gt;

&lt;p&gt;So to add properties with this method it is simple. The syntax is to add the name of the property you want to add, then add colon, and then the value.&lt;/p&gt;

&lt;p&gt;Let’s say that later on in your code, for whatever reason, you want to add more properties to the car object. For example you want to add the speed and the mileage properties.&lt;/p&gt;

&lt;p&gt;To do that all you have to do is to add the following code:&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%2F5cjlanpaoev3dwiuq3f2.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%2F5cjlanpaoev3dwiuq3f2.PNG" alt=" " width="800" height="208"&gt;&lt;/a&gt;&lt;br&gt;
To add more properties to the object the syntax is to write the object name, here it is “car”, followed by a dot, followed by the name of the property.&lt;/p&gt;

&lt;p&gt;If you display the “car” object in the browser’s console you’ll have:&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%2Fvh20st5i8ot9ec95e03v.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%2Fvh20st5i8ot9ec95e03v.PNG" alt=" " width="800" height="77"&gt;&lt;/a&gt;&lt;br&gt;
So now, speed and mileage are also car’s properties.&lt;/p&gt;

&lt;p&gt;To access the properties of the object, same syntax is used. Always write the name of the object, followed by a dot, followed by the name of the property&lt;/p&gt;

&lt;p&gt;So if we want to display the name of the car, or the number of the doors it has or the color…we’ll add the following code:&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%2Ftj1uwxjmojph9c6ipv70.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%2Ftj1uwxjmojph9c6ipv70.PNG" alt=" " width="800" height="328"&gt;&lt;/a&gt;&lt;br&gt;
In the browser you’ll have:&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%2Fkusxvvfo3bm29yajb95t.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%2Fkusxvvfo3bm29yajb95t.PNG" alt=" " width="194" height="198"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;2)- Methods&lt;/strong&gt;&lt;br&gt;
Now let’s say that this car makes a lot of noise, and we want it whenever it makes noise to say: “I’m a white BMW and I make a lot of noise”.&lt;/p&gt;

&lt;p&gt;To do that we’ll add a method to the object which will be a simple function.&lt;/p&gt;

&lt;p&gt;So we’ll declare our object like this:&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%2F72dgphgv0h5ymsqmeqep.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%2F72dgphgv0h5ymsqmeqep.PNG" alt=" " width="800" height="256"&gt;&lt;/a&gt;&lt;br&gt;
Now when displaying the noise method we have:&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%2Fabga60t2ow5i0vxsm1ie.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%2Fabga60t2ow5i0vxsm1ie.PNG" alt=" " width="533" height="97"&gt;&lt;/a&gt;&lt;br&gt;
As you have probably noticed we used the keyword &lt;strong&gt;this&lt;/strong&gt; in the method. In this scope, the keyword &lt;strong&gt;this&lt;/strong&gt; refers to the object itself which is the car.&lt;/p&gt;

&lt;p&gt;So instead of writing &lt;strong&gt;car.color&lt;/strong&gt; or &lt;strong&gt;car.name&lt;/strong&gt;, as we still inside the object and we want to call the object from the inside, &lt;br&gt;
we used &lt;strong&gt;this&lt;/strong&gt;. If we were outside the object, we would have used and called the object by its name which is “car” like we did when we added speed and mileage properties from the outside of the object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)- With the new keyword&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1)- Properties&lt;/strong&gt;&lt;br&gt;
As we have seen we can also create an object using the new keyword with the Object constructor.&lt;/p&gt;

&lt;p&gt;Now if we want to add some properties to the empty object we’ll follow the same syntax as per the Object literal method.&lt;/p&gt;

&lt;p&gt;Meaning we add the name of the property, followed by a colon: followed by the value of the property.&lt;/p&gt;

&lt;p&gt;Let’s say we want to add year of construction and the date of purchase properties. So the code will be:&lt;br&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%2Fse9yj41o4nk32nw1fldr.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%2Fse9yj41o4nk32nw1fldr.PNG" alt=" " width="800" height="131"&gt;&lt;/a&gt;&lt;br&gt;
After displaying the results on the browser we have:&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%2Fvolzoplc61p84za7qsou.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%2Fvolzoplc61p84za7qsou.PNG" alt=" " width="753" height="179"&gt;&lt;/a&gt;&lt;br&gt;
Which means &lt;strong&gt;yearOfConstruction&lt;/strong&gt; and &lt;strong&gt;dateOfPurchase&lt;/strong&gt; become now the object properties.&lt;br&gt;
&lt;strong&gt;2)- Methods&lt;/strong&gt;&lt;br&gt;
To add a method to the object in this case we’ll follow the same syntax for adding properties.&lt;br&gt;
So the code will be:&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%2Fhzhp9kn4xi794m814vyo.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%2Fhzhp9kn4xi794m814vyo.PNG" alt=" " width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in the browser we have:&lt;/p&gt;

&lt;p&gt;![ ](&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a264vy4babvvq3369aao.PNG" rel="noopener noreferrer"&gt;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a264vy4babvvq3369aao.PNG&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)- Using Object.create() method&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1)- Properties&lt;/strong&gt;&lt;br&gt;
To add a property when using &lt;strong&gt;object.create()&lt;/strong&gt; method we can follow the same syntax as we did before.&lt;/p&gt;

&lt;p&gt;Let’s say that for the example we want to add the employee’s salary as a property. So the code will be:&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%2Fp90gv7pvtyxdtdpgq8ux.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%2Fp90gv7pvtyxdtdpgq8ux.PNG" alt=" " width="800" height="354"&gt;&lt;/a&gt;&lt;br&gt;
So in the browser we have:&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%2Fp7gss47qfgmbrqdhkc8z.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%2Fp7gss47qfgmbrqdhkc8z.PNG" alt=" " width="800" height="88"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;2)- Methods&lt;/strong&gt;&lt;br&gt;
Same thing, to add a method to our employee object all we have to do is to use the dot notation as for properties.&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%2Fv4dkt7mrhpljuwvnou9x.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%2Fv4dkt7mrhpljuwvnou9x.PNG" alt=" " width="800" height="428"&gt;&lt;/a&gt;&lt;br&gt;
In the browser we have:&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%2Fa9czs9w7qnxka8miy0m4.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%2Fa9czs9w7qnxka8miy0m4.PNG" alt=" " width="394" height="101"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;d)- Object constructor function&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1)- properties&lt;/strong&gt;&lt;br&gt;
In our previous example we said that the Object constructor function allows us to create a general template that we can use to create our objects.&lt;/p&gt;

&lt;p&gt;And we said that we have 3 houses, each one with its own properties (bedrooms, living rooms…).&lt;/p&gt;

&lt;p&gt;In the template that we will create we will say that our objects, which are our houses, in general, they will have these properties (bedrooms, living rooms, toilets…).&lt;/p&gt;

&lt;p&gt;So to do that we’ll add the following code:&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%2Fc6gx53yoy1yrgz8v3ccw.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%2Fc6gx53yoy1yrgz8v3ccw.PNG" alt=" " width="800" height="231"&gt;&lt;/a&gt;&lt;br&gt;
We added the properties by using &lt;strong&gt;this.nameOfTheProperty&lt;/strong&gt; notation, and as the arguments of the function are the values of the properties, we assigned the values to the properties.&lt;/p&gt;

&lt;p&gt;So now we can create our objects like explained previously:&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%2Fls3gm3u45h5fbx0hzrt1.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%2Fls3gm3u45h5fbx0hzrt1.PNG" alt=" " width="800" height="300"&gt;&lt;/a&gt;&lt;br&gt;
Just to explain what is happening here, for example for The &lt;strong&gt;new House (4, 2, 2, 1, Florida)&lt;/strong&gt;, the constructor object &lt;strong&gt;House&lt;/strong&gt; will take the arguments we gave it which are ” &lt;strong&gt;numbBedrooms&lt;/strong&gt;, &lt;strong&gt;numbLivingrooms&lt;/strong&gt;, &lt;strong&gt;numbToilets&lt;/strong&gt;, &lt;strong&gt;numbYard&lt;/strong&gt;, &lt;strong&gt;location&lt;/strong&gt;” and will replace them with “&lt;strong&gt;4&lt;/strong&gt;,&lt;strong&gt;2&lt;/strong&gt;,&lt;strong&gt;2&lt;/strong&gt;,&lt;strong&gt;1&lt;/strong&gt;,&lt;strong&gt;Florida&lt;/strong&gt;” for the first object, and with “&lt;strong&gt;3&lt;/strong&gt;,&lt;strong&gt;1&lt;/strong&gt;,&lt;strong&gt;1&lt;/strong&gt;,&lt;strong&gt;1&lt;/strong&gt;,&lt;strong&gt;Tokyo&lt;/strong&gt;” for the second object and so on…&lt;/p&gt;

&lt;p&gt;When the constructor does that what we’ll have after that is : &lt;strong&gt;this.bedroom=4&lt;/strong&gt;, &lt;strong&gt;this.livingrooms=2&lt;/strong&gt;, &lt;strong&gt;this.toilets=2&lt;/strong&gt;, &lt;strong&gt;this.yard=1&lt;/strong&gt;… for the first object. So we have our &lt;strong&gt;house1&lt;/strong&gt; object initialized with its entire properties.&lt;/p&gt;

&lt;p&gt;And the keyword &lt;strong&gt;this&lt;/strong&gt; here refers to House.&lt;br&gt;
&lt;strong&gt;2)- Methods&lt;/strong&gt;&lt;br&gt;
In this example the &lt;strong&gt;House&lt;/strong&gt; constructor does not have any methods, we added the properties only, but no methods.&lt;/p&gt;

&lt;p&gt;But what about if we want our &lt;strong&gt;house1&lt;/strong&gt; object or &lt;strong&gt;house2&lt;/strong&gt; or &lt;strong&gt;house3&lt;/strong&gt; to have a method?&lt;/p&gt;

&lt;p&gt;Well, we can add methods to our objects without any problem. The way we’ll do it is with the dot notation as always.&lt;/p&gt;

&lt;p&gt;Let’s say that we want to add a method which is a function that will say: “&lt;strong&gt;Hey, welcome to the house!&lt;/strong&gt;“.&lt;/p&gt;

&lt;p&gt;So the code will be:&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%2Fv45vd8sjupm6ogm92ae8.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%2Fv45vd8sjupm6ogm92ae8.PNG" alt=" " width="800" height="444"&gt;&lt;/a&gt;&lt;br&gt;
So now if we display &lt;strong&gt;house1&lt;/strong&gt; in the console we’ll have:&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%2F09gpufzh48dk22ysisnq.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%2F09gpufzh48dk22ysisnq.PNG" alt=" " width="756" height="183"&gt;&lt;/a&gt;&lt;br&gt;
So here as you can see, we have the &lt;strong&gt;house1&lt;/strong&gt; properties displayed and we have also the &lt;strong&gt;greet()&lt;/strong&gt; method, which means that this method is added to our object.&lt;/p&gt;

&lt;h2&gt;
  
  
  4)- Conclusion
&lt;/h2&gt;

&lt;p&gt;JavaScript Objects are kings of this language. Knowing how to use them is a crucial step in a webdeveloper journey.&lt;/p&gt;

&lt;p&gt;In this tutorial we have seen what an object means and how to add and access objects properties and methods.&lt;/p&gt;

&lt;p&gt;Hope this tutorial was useful.&lt;/p&gt;

&lt;p&gt;For more tutorials check my blog: &lt;a href="https://purpose-code.com/" rel="noopener noreferrer"&gt;Purpose Code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
