Java script tutorial – 5 Types

In Last tutorial we have seen briefly about functions. Technically speaking Java script functions has lot new features and concepts that has to be specifically discuss in detail but for beginner tutorial lets keep the things that we have seen so far with functions and start  taking a look at Java script types as a part of  progressive learning.
Java script Types

Java script Types

String  — In Java script there is no separate type called Character. Any individual character or set of characters are set to fall under the type String .
 
Numbers  — In Java script there is no separate type called integer, decimal, float, long, etc all numerical values fall under the type Number.
 
boolean — There is only two value in this type and that is either “true” or “false”.
 
null  —  A Java script type whose value is not know.
 
undefined — a Java script type that is different from null.
 
Note : Do not prank your head and baffled why null and undefined are different , just go on with the flow and follow the tutorial.
 
In Java script all non zero numbers are equivalent to the boolean value “true”.  Which mean that following  statement would produce “I am a non zero number”.

if( 5) {
print(“I am a non zero number”);
}

Similarly 0 is equivalent to the boolean value false. which means that following statement would produce “I am zero”

if(0){
print(“I am a non zero number”);
} else {
print(“I am zero”);
}

Apart from 0 , “” (empty string ), null undefined are also equivalent to the boolean value false.

 

Post a Comment

Your email is never published nor shared. Required fields are marked *