DEV Community

Umar Shehu
Umar Shehu

Posted on

Basics of JavaScript Programming Language

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

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

  • 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.

How to Open Javascript Console from a Browser

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

  1. Open your preferred browser (Google Chrome or Mozilla Firefox)
  2. Right-click on the mouse.
  3. Select the option inspect.
  4. Click console on the upper panel. A blank screen with a blinking cursor will appear.
  5. 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

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:

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

Enter fullscreen mode Exit fullscreen mode

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:

'tea' // Example of a single quote string
'school calendar'
"click on the above link" //Example of a double quote string
"javascript"
Enter fullscreen mode Exit fullscreen mode
  • Variables: Variables are data types that hold a value. Below is an example of variables.
const name = "Jacob";
const occupation = "student";
const height = 23;
Enter fullscreen mode Exit fullscreen mode

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.
+ // addition operator 
- // subtraction operator
* // multiplication operator
/ // division operator
Enter fullscreen mode Exit fullscreen mode

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 is a fun programming language. 
/* Learn Javascript and 
thank me later */  
Enter fullscreen mode Exit fullscreen mode
  • 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:

// 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
Enter fullscreen mode Exit fullscreen mode
  • 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.

//Examples of case sensitivity
let firstName = "Henry";
function footBall();
const fathersAge = 59;
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)