Java vs Typescript Syntax
Hi, the post is only related to the comparison between the basic syntax in Java & Typescript.
We may need a class and a main function in Java to print a text in the console unlike in Typescript.
Syntax Differences b/w Java & Typescript:
Functions:
Variables inside a Class:
Deep Dive into the Typescript:
Types:
When we try to return number instead of String for string type function, it throws error
Always throws error when we try to return value that is not defined
Not only primitive types but also values can be assigned as types.
It throws error if an undefined value is being returned
The main advantage of using types is not only it strict developer to give invalid values but also gives suggestions to use available values.
A function can be a multi-purpose action.
Maybe Method overloading is the solution for Java 🤕
What if a function can be used in 10 different ways, do we have to write 10 different methods??? 🤔
JAVA:
TYPESCRIPT:
Comments
Post a Comment