Javascript Basic Data types

If you want to start working as a web developer, one programming language you have to get familiar with is Javascript. It is one of the most favored programming languages, used by almost 12 million web developers all over the world. And its community is booming every day.

Now that you understand how big the hype of javascript is, let’s know what it is and what it does?
In simple words, Javascript is a programming language that makes websites interactive. We can build static websites with HTML and CSS but javascript gives it life. For many years, Javascript has been ruling the front-end world, then Node.js came on the scene. With node.js in the game, we can build both front and backend with one single language. So, now it has become a high-level, lightweight language with just in time compilation.

There are 2 main variable types in javascript:

1.Primitive type :

  • String: A series of characters. Strings can be declared in two ways, using string template (double quotes) and String Constructor. In the given example,firstString is declared using string template and secondString is declared using String constructor.
String Data Type
  • Number: Numbers limit from -(253 − 1) and 253–1 like -1,-2,-3,0,0.5 etc.Numbers can be fractional,negative,posive or exponential.
Number Data Type
  • Boolean: Boolean represents either true or false. It is mostly used for testing if any condition is true or false.
Boolean Data Type
  • Null: null is a variable that does not have any value.
null Data Type
  • Undefined: A variable that is not assigned to any value or not declared at all.
undefined Data Type
  • Symbol: After creating a symbol, its value is kept private and for internal use.

2.Objects :

  • Object: Objects are used to store properties( named value) and methods(functions that use those properties).In the given example,person is an object. It has name,number and color properties and a method(function of an object) named sayApple which returns a string.
Object Data Type
  • Function: Functions are created to perform a particular task when it is called or invoked. Here addItems is a function that has two arguments Item1, Item2, and return(Item1+Item2). When it is called after passing two arguments it will add those arguments and return the result.
Function Type data