Basics of JavaScript Programming Language
Published: 2024-07-04 12:26:40

#### Introduction

A sound foundational knowledge of Javascript syntax is a good foundation for anyone starting to learn Javascript programming language. Javascript is the core programming language of the web

Let me guide you on your journey to exploring the basics of JavaScript and its wide range of applications.

![Javascript Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltgrb2504y5zkty59ztj.png)

**What is Javascript?**

Javascript(JS) is the major component used in developing the web. JS is a lightweight and high-level(human-readable) programming language. 

Javascript with the combination of Hyper Text Markup Language(HTML) and Cascading Style Sheet(CSS), makes a web application interactive and user-friendly.

**Applications of Javascript**

The following are applications of Javascript

- Web development
- Mobile application
- Game development
- Server application
- Web server

![Javascript Application Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2lbrxpzug0zdq2loc2xu.png)

* **Web Development:** Javascript is a scripting language used for web page development. Interactive web pages use HTML, CSS, and Javascript as core components during web development.

Javascript enables the changes of HTML content and attribute values without reloading the web page.

* **Mobile Application:** Javascript frameworks like Tatnium and Cordova are used to create hybrid or native mobile applications, for various platforms, like IOS(iPhone Operating System), Android Operating System, and Windows Operating System. 

The following is a list of Javascript frameworks used in mobile app(application) development.

* Ember.js
* Ionic
* React Native
* Mobile Angular UI(user interface)


* **Game Development:** Javascript, HTML5, and API(Application Programming Interface) like WebGL are used to build games. 

Javascript library like EasleJS provides rich graphics for games.

* **Server Applications:** Node.js, an open-source (free) Javascript framework, is used by developers to create server-side software.

Developers also used Node.js to write, test, and debug code faster, and scale network applications.

* **Web Server:** Node.js creates a web server. Node.js HTTP module uses the 'createServer()' command to create a server.

<h4 style="text-align: center;"> How to Open Javascript Console from a Browser</h4>

Follow the steps below to open the Javascript console from a browser:

1. Open your preferred browser (Google Chrome or Mozilla Firefox)
1. Right-click on the mouse.
1. Select the option *inspect*.
1. Click *console* on the upper panel. A blank screen with a blinking cursor will appear.
1. Type your basic Javascript commands on the blank screen.

#### Javascript Syntax

Javascript programming language was designed to operate using defined rules called *syntax*. Two Javascript values are Literal(or Fixed) and Variable Values.

Note that Numbers and String values are classified under Literal values. Also, a semicolon (;) is used to identify the end of a Javascript statement.


![Javascript Syntax](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vgiqdlrsk8r45u1lkkra.png)

The following is a list of Javascript syntax:

* Numbers
* Strings
* Variables
* Operators
* Comments
* Keywords
* Camel-case
* Case Sensitive

* **Numbers**: Numbers are in the form of whole numbers or decimal numbers. Examples of numbers are:

```javascript
// Here are examples of numbers
23 // This is a whole number
67
109
12.8 // This is a decimal number
1.2
6.9

```
The forward slashes are called ***comments***. Comments are explained later.

* **Strings**: Strings are quoted alphabet, word, phrase, or sentence. String are identified with a single or double quotation.

Find examples of string below:

```javascript
'tea' // Example of a single quote string
'school calendar'
"click on the above link" //Example of a double quote string
"javascript"
```

* **Variables**: Variables are data types that hold a value. Below is an example of variables.

```javascript
const name = "Jacob";
const occupation = "student";
const height = 23;
```
In the above example, the variable `const name`, `const occupation`, and `const height` hold values of `"Jacob"`, `"student"`, and `23`. The word ***const*** will be explained in a subsequent section.

* **Operators**: Operators are the basic symbols used for mathematic operations. The following are examples of operators.

```javascript
+ // addition operator 
- // subtraction operator
* // multiplication operator
/ // division operator
```

3 + 45
6 - 5
8 * 10
12 / 3


* **Comments**: Javascript comments give clarity to a piece of code. The console or interpreter omits comments intentionally. Two forward-slashes (//) are used for a single comment.

Multiple comments use a single forward-slash (/) and an asterisk (*), at the beginning of a statement or a code, and a single asterisk (*) and a backslash (/) at the end of a statement or a code.

The following are examples of a single line and a multiline comment.

```javascript
// Javascript is a fun programming language. 
/* Learn Javascript and 
thank me later */  
```

* **Keywords**: Javascript keywords are called *reserved words*. Javascript keywords are 63 in number. Below are some lists of reserved keywords:

* let
* const
* var
* function
* alert
* static
* this
* try
* while 

* **Camel-case**: Javascript camel-case is a standard format used to combine words to form a meaningful variable name. Examples of camel-case:

```javascript
// Below are examples of camel-case
first_name
birth_date
javascript_varibales

// Using hyphen (-) to combine words in a valid declaration of a variable name
old-age
javascript-syntax
```

* **Case sensitivity**: In Javascript, keywords, variables, and function names, are typed in a consistent format to conform to capitalization rules of case sensitivity.

Below are examples of case sensitivity in Javascript.

```javascript
//Examples of case sensitivity
let firstName = "Henry";
function footBall();
const fathersAge = 59;
```

**Final points**

The header "What is Javascript?" captured an overview of the Javascript programming language. Subsequent headers introduced the reader to the applications and syntax of the programming language.

Javascript is the major component behind almost all the cool, user-friendly, and responsive web pages you have visited. Imagine knowing Javascript, and applying the knowledge in a particular field of interest.