With our basic class if we now go to the dist folder and we inspect the app J as file we see what is
generated in JavaScript and there you see we have essentially the same code.
Two important differences are that the name field which we have here does not exist like this here in
the class.
This would actually be supported in modern javascript but it depends on the words of JavaScript you're
building for.
So in iOS 6 alone it's not supported actually.
And of course what's also missing is the type assignment.
We do have our constructor logic though and indeed this is how you do add properties to do to be created
objects.
In vanilla javascript when not using the latest version of JavaScript where it is fields and text would
also be supported.
So this is what I have in JavaScript.
Now it gets interesting however if we go to the T as conflict JS and file and we've switched the target
from iOS 5 to iOS 6 and comment out lip here so that the correct and recommended libraries are added
by typescript automatically.
If you're not saved as config file and you go back to app j ust you see something totally different
and that's pretty interesting what we see here.
What do we have here.
Well what we need and half here is a so-called constructor function constructor function is something
which is built into javascript which has basically been there for ever you could say and this is vanilla
non modern javascript is a way of creating object blueprints.
It's a function which is called with help of the new keyword and then all of a sudden magically this
function even though it has no return statement inside of it does return something as you see when we
call it here it returns an object a new object which will have a name prop..
So this concept is not new it's not introduced by modern JavaScript or by typescript the idea of having
blueprints for objects has been around the javascript for a very long time in the past.
However we had to use constructor functions and since this could be a bit unintuitive especially to
developers who might have worked with different programming languages modern javascript introduced the
idea of classes of this cleaner syntax and typescript supports this as well.
And because of type scripts powerful compilation you can choose where you want to compile the older
style which of course works in Web browsers or introduce more modern iOS 6 style which we saw before
which looks very much like this year.
The key takeaways that we have this feature built into javascript and supported by typescript that we
can define object blueprints.