Skip to content

Commit e6f56ed

Browse files
committed
intro to ts
1 parent 563d87e commit e6f56ed

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

TS/Basics/intro.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,24 @@ let number: number = 6;
1515
// number = "" // Type 'string' is not assignable to type 'number'.
1616
console.log(number);
1717

18-
let userID: number = 334455;
18+
// ': dataType' is not required when we are directly declaring the value. It is redundant. TS is smart enough to figure it out itself.
19+
let userID = 334455;
20+
// userID = 4454.3
1921
console.log(userID);
2022

2123
// Boolean
2224
let isLoggedIn: boolean = false
2325

26+
// Any
27+
// TypeScript also has a special type, any, that you can use whenever you don’t want a particular value to cause typechecking errors.
28+
// You usually want to avoid this, though, because any isn’t type-checked. Use the compiler flag noImplicitAny to flag any implicit any as an error.
29+
30+
let hero;
31+
32+
function getHero() {
33+
return "SpiderMan";
34+
}
35+
36+
hero = getHero()
37+
2438
export {}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy