<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JavaScript Designer</title>
    <description>The latest articles on DEV Community by JavaScript Designer (@javascriptdesigner).</description>
    <link>https://dev.to/javascriptdesigner</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%2F787534%2Fcbedef1c-3a40-4074-aedd-3425afbc6d63.png</url>
      <title>DEV Community: JavaScript Designer</title>
      <link>https://dev.to/javascriptdesigner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/javascriptdesigner"/>
    <language>en</language>
    <item>
      <title>What are CSS Variables and How to Use Them</title>
      <dc:creator>JavaScript Designer</dc:creator>
      <pubDate>Thu, 10 Feb 2022 17:39:07 +0000</pubDate>
      <link>https://dev.to/javascriptdesigner/what-are-css-variables-and-how-to-use-them-20ii</link>
      <guid>https://dev.to/javascriptdesigner/what-are-css-variables-and-how-to-use-them-20ii</guid>
      <description>&lt;p&gt;CSS variables give you the opportunity to declare variables in your CSS code. Currently, the support is around 96%, which means you should be able to use it without worrying. Of course to be at 100% confidence, you can always check Can I use to make sure that you are not trying to target a browser that is not capable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using the :root psuedo-class
&lt;/h3&gt;

&lt;p&gt;Custom properties or CSS variables allow us to re-use a variable property to substitute inside of a CSS property. Let's take a look at an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="py"&gt;--my-bg-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.my-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--my-bg-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.my-other-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--my-bg-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our example above, we are declaring a variable name under :root psuedo-class. When we define our variable --my-bg-color under this psuedo-class, we are able to use this anywhere globally in our code. We call the variable in our code using the var() function provided. This injects the property value of --my-bg-color inside our property value so the output would replace the statement with the color blue in this case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using the var() function
&lt;/h3&gt;

&lt;p&gt;The var() function can accept a default or fallback value to the property value if our custom variable name is not defined or available.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-other-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--my-bg-color-value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the scenario above, if the value of --my-bg-color-value is not available, then the default value of red will be called in this case and used. We can also add more variables to the check if needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-other-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--my-bg-color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--my-bg-color-value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are checking for two variables, and if neither are found then we default the value to be red. Do note that doing this may cause performance issues as it takes more time to parse through the variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;CSS variables are great to use in your CSS to declare custom values&lt;/li&gt;
&lt;li&gt;We declare our variables inside the :root psuedo-class&lt;/li&gt;
&lt;li&gt;Using the var() function we can call our custom property inside of a property&lt;/li&gt;
&lt;li&gt;You can chain multiple calls as the second argument to var(), but there may be performance implications&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>css3</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Var, Let, Const Variable Declaration</title>
      <dc:creator>JavaScript Designer</dc:creator>
      <pubDate>Wed, 12 Jan 2022 04:16:44 +0000</pubDate>
      <link>https://dev.to/javascriptdesigner/var-let-const-variable-declaration-35go</link>
      <guid>https://dev.to/javascriptdesigner/var-let-const-variable-declaration-35go</guid>
      <description>&lt;h3&gt;
  
  
  What is a variable?
&lt;/h3&gt;

&lt;p&gt;In every programming language, we have something called a &lt;strong&gt;variable&lt;/strong&gt;. Let's look at a definition of a variable to understand what it means, I just googled this btw:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;not consistent or having a fixed pattern; liable to change.&lt;/li&gt;
&lt;li&gt;a data item that may take on more than one value during the runtime of a program.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;So taking this into consideration, we can say that a &lt;em&gt;variable is an item of data that may change over time&lt;/em&gt;. I like to think of a variable as a bucket which is empty and can be filled in with any value that is allowed. There are two parts in using a variable in JavaScript, &lt;strong&gt;declaring&lt;/strong&gt; the variable and &lt;strong&gt;assigning&lt;/strong&gt; it a value.&lt;/p&gt;

&lt;p&gt;To use a variable, we use a reserved keyword followed by a variable name, and optionally assign it a value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Var in JavaScript
&lt;/h3&gt;

&lt;p&gt;Originally, using the keyword  &lt;code&gt;var&lt;/code&gt; followed by a variable name was the only way we were allowed to declare a variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var variableName = "hello world"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example statement above, we are &lt;em&gt;declaring&lt;/em&gt; a variable with the keyword &lt;strong&gt;var&lt;/strong&gt; and &lt;em&gt;assigning&lt;/em&gt; it a &lt;strong&gt;value&lt;/strong&gt; of &lt;em&gt;hello world&lt;/em&gt;, which is of the data type string. Now that we have a variable, by definition, we can change the value of that variable. Which means we can do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var variableName = "hello world"
var variableName = "something else"
// or we can assign it any other acceptable data type in JavaScript
var variableName = 99
var variableName = true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;var&lt;/code&gt; declares the variable either using a &lt;strong&gt;functional-scope&lt;/strong&gt; or a &lt;strong&gt;global-scope&lt;/strong&gt;. A functionally-scoped variable is a variable inside of a &lt;em&gt;function&lt;/em&gt;. A &lt;strong&gt;function&lt;/strong&gt; is basically a small program with statements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// here we have var in a global-scope, as it is not inside any function thus living "globally"
var variableName = "hello world"

function newFunction() {
// here we have var in a functional-scope
var variableName = "hello world"
 return variableName
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The initial &lt;code&gt;variableName&lt;/code&gt; variable is living in a "global" scope, while the one inside the function keyword is living inside of the "function" scope.&lt;/p&gt;

&lt;p&gt;JavaScript has the concept of &lt;strong&gt;hoisting&lt;/strong&gt;, which means to "raise up" or "pull up", and so before any code is executed, it will hoist the &lt;em&gt;declaration&lt;/em&gt; part of any function, variable, or class to the top of its respective scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// we are calling the function before we are declaring it
console.log(newFunction())
function newFunction() {
var variableName = "hello world"
 return variableName
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will work fine, however if we try this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(newVariable)
var variableName = "hello world"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will get an error, as the value of &lt;code&gt;variableName&lt;/code&gt; would be &lt;code&gt;undefined&lt;/code&gt;. The reason for this is that the declaration of the variable has been hoisted, not the assignment. The default assignment &lt;code&gt;var&lt;/code&gt; receives is &lt;code&gt;undefined&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// this will be undefined
console.log(newVariable)
var variableName
variableName = "hello world"
// at this point we have assigned it a value, so it will give us the value
console.log(newVariable)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Let in JavaScript
&lt;/h3&gt;

&lt;p&gt;The keyword &lt;code&gt;let&lt;/code&gt; will "let" us (see what I did there) declare a variable which only lives in a &lt;strong&gt;block-scope&lt;/strong&gt;. The block-scope is a statement used to group statements. It is bound within a pair of opening and closing curly braces ({ }). Assignment using &lt;code&gt;let&lt;/code&gt; is optional, and as with &lt;code&gt;var&lt;/code&gt;, it will have a default assignment of &lt;code&gt;undefined&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// this function is using a block statement
function newVariable() {
 let textVariable = "hello world"
 return textVariable
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, &lt;code&gt;textVariable&lt;/code&gt; lives inside the scope of the &lt;code&gt;newVariable&lt;/code&gt; function and it cannot be references outside of it. The keyword &lt;code&gt;let&lt;/code&gt; is used for updating a variable after it has been defined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let textVariable = "hello world"
if (textVariable) {
 textVariable = "something else"
}
console.log(textVariable)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Const in JavaScript
&lt;/h3&gt;

&lt;p&gt;The third type of variable declaration we have in JavaScript is &lt;code&gt;const&lt;/code&gt;. With this keyword, we can declare a variable, but we cannot reassign the variable as we can with &lt;code&gt;var&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const VARIABLE_NAME = "hello world"
// this will give us an error
VARIABLE_NAME = "something else"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By convention, constant variables are usually all uppercase characters. Of course that is not always the case. One thing to note though, is that even though you cannot reassign another value to a variable declared with &lt;code&gt;const&lt;/code&gt;, you can update an object or an item in the array if it is declared with a &lt;code&gt;const&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newObject = {
 name: "Sam",
 age: 29
}
// you can do this
newObject.name = "John"
// but you cannot do this
newObject = {
 name: "John"
 age: 33
}
// you can also do this
const newArray = ["Sam", "James"]
newArray.push("Jones")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Quick Takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You may still see variables declared in the wild using var&lt;/li&gt;
&lt;li&gt;Use let if you have a variable which will change its value during the course of the program&lt;/li&gt;
&lt;li&gt;Use const to declare variables which will hold values which may not change, but remember it does not provide a safety for changing properties in an object or items in an array&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>variables</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Hello World</title>
      <dc:creator>JavaScript Designer</dc:creator>
      <pubDate>Fri, 07 Jan 2022 04:35:49 +0000</pubDate>
      <link>https://dev.to/javascriptdesigner/hello-world-3n9m</link>
      <guid>https://dev.to/javascriptdesigner/hello-world-3n9m</guid>
      <description>&lt;h2&gt;
  
  
  Howdy!
&lt;/h2&gt;

&lt;p&gt;My name is Asif Kabani and I am a Front End Developer.&lt;/p&gt;

&lt;p&gt;I have been a developer for quite some time now, and I wanted to start this blog to help myself, and if the world wide web is willing, to be able to help others.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Starting Experience
&lt;/h3&gt;

&lt;p&gt;It started around some time, I believe it was the year 1999. I took a class called HTML and CSS in high school. I was instantly addicted at what I could do. Of course this was the era of the dancing gifs all over the web, so my class project page was just that.&lt;/p&gt;

&lt;p&gt;I tried taking another course in high school after that introduced computer science. I dropped that class as it seemed difficult for me to understand programming and also the teacher was no help. This was unfortunately the times we were living in.&lt;/p&gt;

&lt;p&gt;I was never a studious or a "smart" kid in school. I was always around the "C" averages. Growing up was tough trying to figure out what I wanted to do in life. I went to community college and took some basic academic courses, until I ultimately found The Art Institute of Houston. There I enrolled myself in a program called Interactive Media Design, which was an associates degree plan.&lt;/p&gt;

&lt;p&gt;We were taught a plethora of different technologies and classes which included audio, video, graphic design, and web design. The only web design class they taught was basic HTML/CSS and PhotoShop with ImageReady. ImageReady was an extension to PhotoShop which let you slice up your graphics and you could export out a HTML website from it.&lt;/p&gt;

&lt;p&gt;The one programming class I did have was called Macromedia Director. This is where I actually got a first taste in some logical programming. The language which it used was called Lingo. I loved what I could do using this programming language and created a cool portfolio piece.&lt;/p&gt;

&lt;h3&gt;
  
  
  Into the Workplace
&lt;/h3&gt;

&lt;p&gt;Coming out of school, I was working in a mom and pop company called Meyer Instruments, which was a company which sold Leica Microscopes and products. My work involved using Dreamweaver to code and update their website using the GUI mostly along with jQuery snippets for functionalities. I was so relaxed and on auto-drive that I told myself this was the best I could do with what I had learned.&lt;/p&gt;

&lt;p&gt;Eventually, I moved on but I gave many years of my life to that company. I moved on to other projects and was mostly always using HTML/CSS and jQuery snippets for functionalities. I did not know what I was actually doing but I knew enough to modify jQuery snippets and make it functional as to how I want it to work.&lt;/p&gt;

&lt;p&gt;After this, I got into WordPress for many years. Again, as I was afraid and told myself "I am no programmer," I always opted to the easy way out of programming. WordPress had so many ready to go templates and plugins I just relied on that. It was not until around the year 2013 or so when I finally decided I needed to do more. React was prevalent in the industry and everyone I saw, it required at the least JavaScript and React.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Want to Learn
&lt;/h3&gt;

&lt;p&gt;I decided to go to a bootcamp to learn some JavaScript and React. I was amazed at how much fun I was having coding using vanilla JS and React. I realized that I just had low to no self-confidence when it came to programming, which stemmed from my bad experience in high school. I wish I had done this much sooner.&lt;/p&gt;

&lt;p&gt;Anyways, this was a short introduction about me and my small journey from nothing to a developer. As of this post, I am 39 years old and I will be 40 coming in March 2022. I told myself a long time ago I would write a blog. But I always have been a pessimist so it was hard to not negate what I thought, like I am not good enough. I am finally starting a blog and hope to keep doing this going forward. I would love to even have just one impact on someone.&lt;/p&gt;

&lt;p&gt;As I am getting older, I am trying to teach this old dog some new tricks.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
