xxxxxxxxxx
// What differs typescript from javascript is the strict usage of types.
// Javascript is a loosely typed language,
// while Typescript is strictly typed.
// Javascript
let car = 'BMW';
let age = 15;
// Typescript
let car: string = 'BMW';
let age: number = 15;
xxxxxxxxxx
JavaScript:
function my_function(my_param) {
console.log('do something');
}
TypeScript:
function my_function(my_param: any) {
console.log('do something');
}
xxxxxxxxxx
TypeScript adds strict typing to JavaScript.
It helps to reduce the number of errors in your code.
Apart from strict typing, TypeScript introduces
a plethora of features like Interfaces, Mixin classes, Enums
and much more, as discussed later in the article.
xxxxxxxxxx
They are really almost the same theres not the same param types like
JAVASCRIPT is function myFunction(param)
while typescript is
function myFunction(the_param: something)
xxxxxxxxxx
The main reason that i have explored that makes typescript different from
javascript is its strict/static typing for variables or objects.
Strict typing can mainly involves advantages like,
- it enhance code redability.
- it enhance maintainability for the data and makes more controlled data flow
within the project.
xxxxxxxxxx
TypeScript is a statically typed language. Unlike JavaScript, where types
are determined at runtime, TypeScript requires explicit declaration of types
during development. This means that you have to specify the types of variables,
parameters, and return values before running the code.
xxxxxxxxxx
All JS valid code is typescript valid code.
Typescript is the superset of JS.
Typescript is strictlty typed in comparison to JS.