Learning JavaScript the easy way: JavaScript Grammar
Tags: javascript, beginners, webdev, firstpost
Published: 2021-03-10 13:56:26

Hi, welcome to my first post on [dev.to](https://dev.to").

This post will be the first part of the "Learning JavaScript the easy way" series.

The decision to start this series came out of the desire to teach JavaScript concepts in the most understandable way to people who may be struggling with it and also get a deeper understanding of it.

This tutorial is best suited for beginners as it promises a smooth ride and a better understanding of JavaScript concepts from the ground up.

In this part, you will learn about JavaScript grammar, some of which include case-sensitivity, identifiers, comments, statements, and expressions.

Let's dive in 🚀🚀

##Javascript Grammar

Every language has its diction, be it a programming language or the native languages we use to communicate with ourselves and Javascript isn't an exception.

###Case Sensitivity
JavaScript is a <i>case-sensitive</i> language. This implies that the keywords, variable, function, and many other identifiers must always have consistent capitalization. Therefore, a variable name like <code>user</code> is significantly different from <code>User</code>.


###Identifiers
An Identifier can simply be referred to as a name.
In JavaScript, identifiers are used to name variables, functions, parameters, or classes. But these identifiers have certain rules that must be conformed to:

- A JavaScript identifier must start with a letter, underscore (_), or a dollar sign ($). Subsequent characters can also be digits (0–9), digits, underscores, or dollar signs.

The letters being referred to in this context are not limited to ASCII characters also but may extend to Unicode characters also.

It has become a convention among Javascript developers to use camel case for identifiers, this means that the first letter is lowercase, and each additional word starts with a capital letter. Although it is not mandatory as there are other conventions like <code>kebab case</code>, <code>snake case</code> that can also be used, they just have to abide by the identifier rule

The following are identifier names declared in camelcase

```Js
greetingsFromNigeria
containsNumber
isString
routeHere
```

##Comments

They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.

Comments are unexecuted statements in Javascript (more on statements later).

A line of code that comes after double slashes // or block of codes that comes between /* and */ are treated as a comment in JavaScript.
For example

```Js
let foo = 6; //  I will be executed
// let bar = 7;  I am not executed

/*
This code won't run.
Because it is a comment
*/
```

## Statements
A statement is a piece of code that can be executed and performs some kind of action.

Although JavaScript doesn't require a statement to end with a semicolon(;), it is recommended to be used when ending a statement. 

Personally, I think it makes code readable.
You can use a code block that begins with a left curly brace <code>({)</code> and ends with the right curly brace <code>(})</code> to combine multiple statements as follows:

 For example, 
```Js
let today;
if (true){
today = 'Monday';
} else {
today = 'Tuesday';
}
```

## Expressions

An expression is a piece of code that can be evaluated to produce a value. 
For example, the following illustrates an expression that involves a and b:
```Js
a + b 
```

## Reserved Keywords
There are some keywords that are reserved in JavaScript these keywords cant be used to name variables some of which includes 

<code>await</code>,<code>break</code>,<code>case</code>,<code>catch</code>,<code>default</code>,<code>const</code>,<code>continue</code>,<code>debugger</code>,<code>delete</code>,<code>enum</code>,<code>else</code>,<code>export</code>,<code>do</code>,<code>extends</code>,<code>false</code>,<code>finally</code>,<code>for</code>,<code>function</code>,<code>void</code>,<code>static</code>.

There are many other reserved words and keywords in JavaScript that aren't mentioned here, but the good thing is you don't have to memorize them all. However, if you wish to check out other reserved words you can find them [here](https://www.w3schools.in/javascript-tutorial/keywords/").

In the next part, we will be discussing <i>Variable</i>, its declaration, hosting amongst many basic concepts.

As this is my first post, I would like the opinions of experts on how to make this better

Thank you for your time.