typescript vs js code example
Example 1: TypeScript vs JavaScript
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.
Example 2: typescript vs javascript
JavaScript:
function my_function(my_param) {
console.log('do something');
}
TypeScript:
function my_function(my_param: any) {
console.log('do something');
}
Example 3: typescript vs javascript
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)
Example 4: typescript vs javascript
let car = 'BMW';
let age = 15;
let car: string = 'BMW';
let age: number = 15;