JS Introduction


JavaScript is one of the most important programming languages. It’s definitely the future of the web. More and more logic is being introduced on the client side to achieve a lightning fast user experience. JavaScript also moves to the server side with Node.js.

For this reason, this lesson delves into JavaScript so that by the end of this lesson you will have a good understanding of how it works.

As usual, this lesson starts with JavaScript basics and progresses to more advanced topics.

Starting off with JavaScript

Let’s get started with this recorded live session

Then visit the web page JavaScript For Cats – An introduction for new programmers and start learning about the basic concepts of JavaScript.

You can also watch the following video from Mosh Hamdani explaining what JavaScript actually is and what it’s used for:

The Console

The web console is a tool primarily used to log information related to web pages such as: network requests, JavaScript, security errors, warnings, CSS etc. It enables us to interact with a web page by executing a JavaScript expression in the contents of the page.

In JavaScript, the console is an object which provides access to the browser debugging console. We can open a console in web browser by using: Ctrl + Shift + I for windows and Command + Option + K for Mac. The console object provides us with several different methods, like :

  • log()
  • error()
  • warn()
  • clear()
  • time() and timeEnd()
  • table()
  • count()
  • group() and groupEnd()
  • custom console logs

Here are some examples of how the console looks like in practice:

You can read more about the console and its different methods through this link.

The JavaScript Operators

There are different types of JavaScript operators. Here are some examples:

  • Arithmetic Operators
// Arithmetic Operators are used to perform arithmetic on numbers:
let a = 3;
let x = (100 + 50) * a;
  • Assignment Operators
// Assign the value 5 to x
let x = 5;
// Assign the value 2 to y
let y = 2;
// Assign the value x + y to z:
let z = x + y;
  • Logical Operators
&& 	// logical and
|| 	// logical or
! 	// logical not
  • Comparison Operators
// Comparison operators are used in logical statements to determine
// equality or difference between variables or values. 

== 	// equal to
=== 	// equal value and equal type
!= 	// not equal
!== 	// not equal value or not equal type
> 	// greater than
  • Type Operators

JavaScript variables can be converted to a new variable and another data type by the use of a JavaScript function, or even automatically by JavaScript itself.

typeof 	// Returns the type of a variable
instanceof // Returns true if an object is an instance of an object

Note: Comparison and Logical operators are used to test for true or false.

You can read more about JavaScript operators through the following link.