A data-type, simply put is a type of data. Consider the following values; "4", "6.3", "James".
4 is an Integer type as it is a whole number.
6.3 is a Floats type as it is a values with a decimal point.
James is a String type as it is composed of alphabets. Strings are alphabets, alphanumerics and symbols. Example of this is KAYODE, CSC101 etc.
Arithmetic computations can be performed only on integer values or floating point values. e.g 3 + 5 or 4.634 - 2.423. Strings on the other hand cannot have calculations performed on it. We + Are does not resolve to a mathematical output. At best, strings can merely do what is called concatenation - the joining together of values.
4, 7, 723, 9239 <- Integer values.
9.523, 23.582, 412.9349 <- Floating point values
Kayode, Emmanuel, Townhall, Thesis, Gd24 <- String
There are actually more JS data-types. We have Arrays and Objects.
Array variables are capable of holding more than one value. Consider the example below.
var subjects = [34,"Computer Science",15.23,"Physics","History"];
Variable subjects in the example above holds 5 values. These values can actually be of different data-types. Only Arrays and Objects are capable of this.
Object variables also hold more than a single value. They hold properties and the corresponding values of the properties.
var objHuman = {name:"Kayode", age:25, Address:"Bacita", Phone:"07055518205"};
The variable objHuman is of object type And as shown above, the properties defined for the objHuman are the name, age, Address and phone. Each of the properties have their corresponding values attached to them.
A JS variable can be initialized with any of the data-type mentioned above.
Joseph Kayode Agbede
4 is an Integer type as it is a whole number.
6.3 is a Floats type as it is a values with a decimal point.
James is a String type as it is composed of alphabets. Strings are alphabets, alphanumerics and symbols. Example of this is KAYODE, CSC101 etc.
Arithmetic computations can be performed only on integer values or floating point values. e.g 3 + 5 or 4.634 - 2.423. Strings on the other hand cannot have calculations performed on it. We + Are does not resolve to a mathematical output. At best, strings can merely do what is called concatenation - the joining together of values.
4, 7, 723, 9239 <- Integer values.
9.523, 23.582, 412.9349 <- Floating point values
Kayode, Emmanuel, Townhall, Thesis, Gd24 <- String
There are actually more JS data-types. We have Arrays and Objects.
Array variables are capable of holding more than one value. Consider the example below.
var subjects = [34,"Computer Science",15.23,"Physics","History"];
Variable subjects in the example above holds 5 values. These values can actually be of different data-types. Only Arrays and Objects are capable of this.
Object variables also hold more than a single value. They hold properties and the corresponding values of the properties.
var objHuman = {name:"Kayode", age:25, Address:"Bacita", Phone:"07055518205"};
The variable objHuman is of object type And as shown above, the properties defined for the objHuman are the name, age, Address and phone. Each of the properties have their corresponding values attached to them.
A JS variable can be initialized with any of the data-type mentioned above.
Joseph Kayode Agbede
No comments:
Post a Comment