Typescript Tutorial #4: Mastering Type Annotations in TS with Practical Examples and In-depth Q&A

preview_player
Показать описание
Welcome, "Type Annotations in TypeScript: Practical Examples, Best Practices, and Expert Q&A"

Enhance your TypeScript skills with our comprehensive video tutorial on type annotations. Discover practical examples and learn the best practices for utilizing type annotations effectively. From variable annotations to function parameters and return types, we cover it all.

With a focus on improving code quality and catching errors early, type annotations are a must-know for TypeScript developers. Our expert Q&A segment challenges your understanding and solidifies your knowledge.

Level up your TypeScript game and become a pro with type annotations. Watch now for invaluable insights and boost your development productivity.

😊 Become Member, get access to perks, free Source code, & more..

⌚ TIMELINE ⌚

0:00 Introduction
0:11 Addressing the problem encountered in the previous video and its solution
3:15 The impact of commenting out the tsconfig file
4:06 Exploring the concept of Type Annotations
6:45 Understanding the different types in TypeScript
7:50 Importance of type checking and ensuring type safety
12:38 Deep dive into Number types in TypeScript
13:40 Practicing assignments with Number types
15:55 Exploring String Types in TypeScript
18:02 Hands-on practice with String types assignments
23:24 Homework assignment for you to reinforce your learning

************* 😍 Must Watch Videos For Web Development 😍 *************

Рекомендации по теме
Комментарии
Автор

Here is the Home Work Guys 🙏

todo 👉 Substring:
Declare a variable longText of type string and assign it a long sentence. Extract the first 10 characters from longText and store them in a variable called shortText.

todo 👉 String Comparison:
Declare two variables str1 and str2 of type string and assign them different sentences. Compare the two strings and store the result (true or false) in a variable called areEqual.

todo 👉 String Template:
Declare variables product and price of type string and number, respectively. Create a string using template literals to display the product and its price in the format "The product {product} is priced at {price} dollars."

ThapaTechnical
Автор

// DAY 4 Ts
// question 1
const longText: string = "This is the long string of the longText variable";

const shortText: string = longText.substring(0, 10);

console.log("shortText:", shortText);

// question 2

const str1: string = "hello";
const str2: string = "hi";

const areEqual: boolean = (str1 == str2) ;

console.log("areEqual: ", areEqual);

// question 3

const product: string = "Biscut";
const price: number = 34;

console.log(`The product ${product} is priced at ${price} dollars.`)

AkashKumar-kgge
Автор

Vinodji this is very good TS course I have ever seen on YouTube. Thank you so much for bringing this series. Easy to understand and in depth explanation. Great job sir.

rachittrivedi
Автор

Recently I see that you improve your videos like video quality, sound quality, editing etc it is more better than your four years before javascript course video quality and by the way your video ending is so good and awesome

itzallabouttech
Автор

Best Typescript series ever on YouTube 🔥

iamakashkumarram
Автор

Thank you sir to providing us your best content. i am your fan from Pakistan, Sindh.
🥰

Ai-Heart
Автор

NaN is a special value in JavaScript representing an invalid number, it is still considered a numeric value.Thats why it is a valid to assign it to a variable of type number in TypeScript.

bpurbil
Автор

In JavaScript and TypeScript, NaN stands for "Not-a-Number, " and it is a special value representing the result of an operation that could not produce a meaningful numeric result. However, its data type is still number. So, NaN is of data type number.

jagdishjena
Автор

Type annotation is help ful to describe the type of the v ariable function parameter function return value with the use : and type

jonnysharan
Автор

1 - todo 👉 Substring:
Declare a variable longText of type string and assign it a long sentence. Extract the first 10 characters from longText and store them in a variable called shortText.
solution: let longText: string = "This is typescript tutorials. The typescript is a superset of javascript programming language";
let shortText: string = longText.substring(0, 10);
console.log(shortText);
2 - todo 👉 String Comparison:
Declare two variables str1 and str2 of type string and assign them different sentences. Compare the two strings and store the result (true or false) in a variable called areEqual.
solution: let str1: string = "Hello";
let str2: string = "World!";
let areEqual: boolean = str1 === str2;
console.log("Output of str1===str2 is :" + areEqual);
3 - todo 👉 String Template:
Declare variables product and price of type string and number, respectively. Create a string using template literals to display the product and its price in the format "The product {product} is priced at {price} dollars."
solution: let product: string = "Laptop";
let price: number = 250;
console.log(`The product ${product} is priced at ${price} dollars.`);

fahadraza
Автор

Sir How much time this series will take to complete? So that i can take out my time everyday to learn this😊?

rahulgupta
Автор

How to get terminal like yours, plz make a video on this 🥺

mdmaaz
Автор

TypeScript Type System: TypeScript ka type system NaN value ko number type ke variable mein assign karne deta hai. NaN ka matlab "Not-a-Number" hota hai, aur yeh ek khaas value hai JavaScript mein jo undefined ya unrepresentable numerical result ko represent karti hai (jaise ke 0 ko 0 se divide karne ka result).

NaN as a number: JavaScript mein NaN ek global object ka property hai aur iski type number hai. Yeh ek primitive data type hai JavaScript mein, aur iska type number hai. Yeh matlab hai ke NaN ko ek numeric value mana jata hai, lekin yeh asal mein ek real number nahi represent karta.

Usage: NaN ko number type ke variable mein assign karna aam hai jab numerical operations kiye jate hain jo undefined ya invalid numbers ka result de sakte hain. Misal ke taur par, agar kisi non-numeric string ko parseFloat ya parseInt se parse karte hain aur wo string number mein convert nahi ho sakti, to NaN return hota hai.

To, yeh code let nanVal: number = NaN; TypeScript mein bilkul valid hai kyun ke NaN ek number type hai, bhale hi yeh ek invalid number ko represent karta hai. Yeh assignment kisi bhi tarah ka type error nahi deta, kyun ke NaN fir bhi number type ka hi hota hai.

lhteodn
Автор

datatype of NAN is number...hence it is valid..

CHETANRATHOD-eqbx
Автор

NAN datatype is number hence it is valid

namitadas
Автор

Also need Electron.js in 2024!
Plzzz ❤

Ahmad-edjr
Автор

From where i can get the source code of this ?

vivekchoudhary
Автор

Hello Thapa: I am new in typescipt. getting error while simple code:
function suam (a:number, b:number):number{
return a+b;
}
console.log(suam(12, 2))

function sum (a:number, b:number):number{ ^ SyntaxError: Unexpected token ':'

pavanparaskar
Автор

1.Declare a variable longText of type string and assign it a long sentence. Extract the first 10 characters from longText and store them in a variable called shortText.


let longtext:string = "Hello, I am varsha prajapati."
console.log(longtext.substring(0, 11));


2.Declare two variables str1 and str2 of type string and assign them different sentences. Compare the two strings and store the result (true or false) in a variable called areEqual.

let msg1:string = "Javascript Programming Language.";
let msg2:string = "Typescript Programming Language.";

let areEqual:boolean = (msg1 === msg2);
console.log(areEqual);


3.Declare variables product and price of type string and number, respectively. Create a string using template literals to display the product and its price in the format "The product {product} is priced at {price} dollars."

let product:string = "camera";
let price:number = 1400;

let item:string = `The product ${product} is priced at ${price} dollars.`
console.log(item);

varshaprajapati-rkpi
Автор

let comitvalue: number = Math.sqrt(16);
console.log(comitvalue);

answer is = 4

pocvbnh