#100DaysOfVanillaJS: JavaScript Lexical Structure, As Explained By Pokemon
Tags: javascript, beginners, webdev, programming
Published: 2020-04-09 12:59:18

---
title: #100DaysOfVanillaJS: JavaScript Lexical Structure, As Explained By Pokemon
series: #100DaysOfVanillaJS
published: true
description: My attempt at explaining the basic rules of writing JavaScript code
tags: Javascript, beginners, webdev, programming
canonical_url: https://taeluralexis.com/2020/04/22/100daysofvanillajs-javascript-lexical-structure-as-explained-by-pokemon/
---
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/for0pwsmq11p86ii7f5t.gif)
Today I want to share a few important rules about writing in JavaScript that I feel is important for you to know, especially if you are just starting your coding journey or overall seeking to better your understanding of the language. As a self-taught developer learning JavaScript, I don't recall finding JavaScript tutorials catered to beginners that explicitly taught the lexical structure of the language so I figured I'd share with you.

Feel free to bookmark this short post to keep as a basic reference as it will be helpful to be mindful of these rules as you start building stuff with JavaScript!

## What Does Lexical Structure Mean?

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1e4bc75l6x0lkmaa1z4p.gif)

It's not as complex as it sounds. Every programming language has a lexical structure, which is a set of basic rules you must follow when you're writing code in a language such as how to write comments and name variables.

## JavaScript Is Written In Unicode

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/olgci1ddbbing70qzdj3.png)

Unicode is an international encoding standard supported by almost every writing system and is used in JavaScript, which means you can use emojis or Japanese characters in your code for instance. If you want to read more about unicode (it's not mandatory learning in order to write JavaScript code), [go here](https://www.interproinc.com/blog/unicode-101-introduction-unicode-standard).

## Whitespace

Whitespace does not affect your code in JavaScript. You can hit indent and tab as much as you want but if I'm working in an already existing codebase, I usually follow their formal or style of indenting. If you're more experienced with coding, you may be aware of tools like Prettier which help format your code to be readable.

### Semicolons Are Optional

Semicolons are generally used to indicate the end of a statement but they are not mandatory. You will not encounter an error if you were to choose to not end a variable you declare with a semicolon. I personally use semicolons because to me it makes code more readable for my eye but you don't have to use them.

### JavaScript is Case-Sensitive
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rkaitg1xedtidg23miqq.png)

The spelling of the names of your variables, functions, keywords and other identifiers must be exact. So that means <em>myName</em> and <em>MyName</em> are not the same. Another example is with booleans, a topic we'll be touching on later in the series. If we were to set a variable to <em>True</em> instead of <em>true</em>, you would encounter an error. 

### Comments
There are 2 different ways to create comments. You can either make a single line comment using 2 forward slashes or create a multi-line comment using a forward slash and an asterisk to create longer, more meaningful comments if you need to. 

### What Are Identifiers?
Identifiers are names. It's how we create references to our variables and functions. You can start any variable name with a dollar sign, underscore or letter. The main rule is to not use numbers as the first character in our identifiers. 

### Reserved Words
Many of these reserved words are already used in JavaScript like <em>let</em> for instance. It would be rather confusing if we decided to create a declare a let variable and name it <em>let</em>.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vkb2puyfum9ekai5uvlo.png)

### Literals
A literal is a piece of data that appears directly in a program such as numbers, strings (text encapsulated by quotation marks), boolean values and null. 

So...What are we learning next?

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xwx9arrvxu2hdi09xdnf.gif)

So next we will continue on diving deeper into the primitive data type strings and the different ways we can manipulate them so this will get way more fun and practical! Thanks for reading, hope you enjoyed!