Just Getting Familiar with JavaScript

Khadiza Rafa
5 min readNov 2, 2020
JavaScript

If you have still don’t know anything about javascript and yet you’re a web developer then I have a bad news for you !! You abondoned the coolest part of web development.

But don’t worry its never too late. This post will give so some general ideas about the javaScript types and why it’s the coolest?

JavaScript has become one of the most popular web development tool now-a-days. It’s light weight and can perform numerous tasks from developing cool transitions for user interactions in front end to Dom manipulation in back end. JavaScript can do all of it and at the same time it’s easy to learn.

All the web browers use javaScript. Have you heard of JSON ?

JavaScript Object Notation (JSON) is used for data exchanges on internet. NoSQL databases like MongoDB use JSON documents for record storage. Working with JSON is like child’s play if you are familiar with JavaScript.

And besides if you are particularly interested to learn any framework, javaScript can help you there too. AngularJS is a structural framework and mostly used for developing web apps. For back-end we have NodeJs; its an open-source, cross-platform, back-end, JavaScript runtime environment that executes JavaScript code outside a web browser.

If you are still not convinced then go and check out the community size of javaScript in Stack Overflow!!!!!

Now let’s know about some JavaScript Types.

JavaScript Types:

  1. Numbers
  2. String
  3. Boolean
  4. Symbol
  5. Object
  6. Null
  7. Undefined

Before diving in let’s discuss about some operators in JS.

Operators

Numeric operators : + , — , * , / , %

Assignment operators : = , += ,-= , ++

Some other operators used for comparison : ==, ===, !=, < = , > =

Numbers:

The JavaScript Number type is basically like a double value in Java or C#. Values can be converted into integer or float by using built-in functions.

parseInt(value,base) : parseInt can take two parameters. It basically returns an integer value of the selected base.

parseFloat(value) : Unlike, parseInt parseFloat only takes one value and uses base 10 value.

“+” operator is also used for converting values to number

NaN

Not a Number. Usually we get to see this value when we try to convert any string value to number. Any mathematical operation with NaN will result into NaN.

Strings

Strings are special kind of javaScript objects. These string characters can be accessed through different functions. Some of them are:

length : retruns the length of current string

charAt(index_no) : returns the character at provided

toUppercase: converts the string to uppercase

toLowercase : converts the string to lowercase

replace(string_to_be_replaced, string_to_be_repaced_with) : replace one or multiple string with another string value

Boolean

Boolean is the mostly used type in JS. Conditional statements ,switch cases decides on this type.The most confusing part here is to decide which values are true and which are false. For,

False , 0 , empty string (“ “) , NaN , null , undefined — returns false

all other values — return true

Objects

Objects are mostly used in javaScript for storing or retrieving data from databases or many other cases. As there are no other easy way to access values.

  1. Function
  2. Array
  3. Date
  4. RegExp

Function:

Functions are most common term in any programming languages. Let’s continue with our employee example and this time we will use functions to create object.

here we used a function to generate objects. here, this keyword is used to differ the variables. this.name refers to the variable of Employee class and name refers to the parameter passed to this function.

Array:

Arrays are special kind of objects. It’s mostly used data structure for storing data. We will continue with the employee example. Now we will store each employee to an array.

Here we used push function to insert into an array. Inserting element to an array can be sone in various way, I have used this as its easier. In the for loop we used length function to get the length of this array.

Null

Null basically refers to an object having no value. Yes, you null is an object type. Strange right! Well, we all have a misconception about null and undefined. Null and undefined are two different types. Let’s explain with an example

here in this example when the string didn’t matched assigned null to m variable and thus we get 0.

Undefined

Basically when we declare a variable without initializing it, this variable is called undefined. The type of undefined is undefined. There is also a secret undefined is a constant !!! This example will resolve all you doubts hope

--

--