What does it mean by an instance of a data type?

wow! thank you so much for this explanation

1 Like

I love your explaination!!! so clearly and easy to understand in my real life experience. :slight_smile:

1 Like

this really helped me out. this is the power of internet!

1 Like

Hi, best explanation for me :smiley:

But, can I say that Instance are some kind of sub-type of data types? I mean, there’s a way I can imagine in my mind. you talk about:

@joseulisesjuarezparr saying “sub-type” may be a bit confusing, I prefer to say something like : “Jose” can be CLASSIFIED under string data type. But let me just give an example to further explain,

Let us say we have an Aeroplanes object and a cars object.

Instances of the Aeroplanes object include: Airbus A320 , Boeing 737- max.
Now the vehicles which are classified as Aeroplanes are instances of the Aeroplane object and therefore have properties and methods of the Aeroplane object.

some of the properties could be:
wingLength, numberOfEngines, seatingCapacity.

some of the methods could be:
takeOff( ), land( ), elevate( )

This means that any vehicle classified as an aeroplane would have these properties and would perform this functions or methods.

Instances of the cars object include: Toyata Camry and Kia Cerato.
some properties could be:
sizeOfBonnet, sizeOfTrunk, seatingCapacity, color, fourWheeldrive etc

some methods could be:
drift( ) ,start( ), park ( ), accelerate ( ), reverse( ), overtake( ) etc

This means that any vehicle classified as a car will have these properties and methods.

Now relating this to programming.
when we type “Hello world”, in Javascript, it is classified as a string and is therefore an instance of the string data type, this means it would have properties and methods of the string object.
This means we can use a property like .length on a string and a method like .split( ).

When we type 19 it is classified as a number and thus is an instance of the Number data type. This means that it would have properties and methods of the Number object.

It is important to know what data type you are working with so we know the right properties and methods to use.
Just like it would be crazy for a pilot to try to .drift( ) with a boeing 737-max or a driver try to do .takeoff( ) with a car, because only instances of cars can drift and only instances of aeroplanes can fly.
This would be like using .length and .split( ) on a Number data type when they should be used for a string data type

I hope this clarifies any confusion :slightly_smiling_face:


Thank you very much!! :heart_eyes: for taking the time to write your answer in such detail. Everything is much clearer to me. :raised_hands:

Again, thank you very much. :smiley:

1 Like

you’re welcome, happy coding. :slightly_smiling_face:

You will be a good teacher

1 Like

Phenomenal explanation!!

1 Like

6 posts were split to a new topic: Link is not working

Thank you for this analogy. Make’s it a lot easier for beginners to understand the core concept of what instances are!

1 Like

My god this is such an interesting and helpful answer. I love the analogy highlighted in green. Thanks a ton @ruronite !

1 Like

excellent answer bcz its like water into ocean… de :slightly_smiling_face:eply

1 Like

That was an excellent illustration. Very helpful!

1 Like

Thank you so much Sir

1 Like

Impressive explanation pal!
You make it simple, like if you were explaining it to a kid. You’re a great teacher. Thanks for this.


Glad to help, You are welcome :slightly_smiling_face:

perfect way to explain it to beginners like us. getting it 1st hand.

1 Like

Your explanation was really great.

1 Like

Thank you so much! Really appreciated the analogy, it certainly clarified it for me :grinning:

1 Like