Home Works Boolean program function isDivisibleBy4And8(a: number): boolean { // return a % 4 ===0 && a%8 ===0; if (a % 4 === 0 && a % 8 === 0) { return true; } else { return false; } } // fun call console.log(isDivisibleBy4And8(48)); HomeWorks BigInt let sum = bigNumber + anotherBigNumber; console.log(`Sum is ${sum}`); let difference = bigNumber - anotherBigNumber; console.log(`Difference is ${difference}`); let product = bigNumber * anotherBigNumber; console.log(`Product is ${product}`); let division = bigNumber / anotherBigNumber; console.log(`Division is ${division}`); Answer : -> [ Sum is 99079191802150916 Difference is -81064793292668934 Product is 811296384146066771921893777735675 Division is 0 ]
l et sum = bigNumber+anotherBigNumber console.log(sum) let difference = anotherBigNumber-bigNumber console.log(difference) let product = bigNumber*anotherBigNumber console.log(product) let division = anotherBigNumber/bigNumber console.log(division)
we learned in this video about the any type and unknown type . ant type used for the type where we do not assign any type but still want to perform operation its like simple js. but it is not a good way to add cause it is not checcking type and stype safety we compromise. so for that we have unknows type to help in that . we could use unknown type and get the type safety and type checking to perfoe=rm some operation like if (type of a=== boolean) to check the type and if we talk about the type safety we could perfom methods for that type it is available or not .
Hy brother 🖐 I don't understand use of unknown kindly explain it in detail u use unknown in async await function like async function fetchDtaa(): Promise but we all know that async function always return a promise so why u use unknown and we can also check type of and we can also check type of any like let fav: any = 12; fav = true; console.log(typeof fav); so why we use unknown please explain
I still have doubt regarding this “any vs unknown”, but the promise thing, I know that. We know the function will return promise but what type of value will promise return when resolved, so we use that in angular brackets such as . Let say there is a function which is used to get user’s address by using an api. So we can declare function as : function getUserAddress(userId:number) : Promise { … } Now if we use await, const addr:string = await getUserAdrress(10); This will work and typescript will know the datatype of resolved value. If you try to do something like, const result:number = await getUserAddress(5); Typescript will give error because you mentioned that promise will resolve to a string value, but you storing the result in a variable of type number
Also now i got the main difference between any and unknown. Just googled this, If you use following: let n:any = 7; n = n.toUpperCase(); This will not give any compile time error, but if you use following let a:unknown = 10 console.log(a.toUpperCase()) It will give compile time error, and force you to use type checking i.e let a:unknown = 10 if ( typeof a === “string”) { console.log(a.toUpperCase()) } Hope you get this
Here is an Example // this is any let apple: any = 12; apple = "hello"; apple = true; apple = 12312312; let newApple = apple + 12; // we can do it. it will work let banana: unknown = [1, 2, 3, 4, 5]; // currently for example, it is coming from api, which is unknown to us // let newBanana = banana.map((el:number) => el); // if we try to map directly, it will wont let you compile. because maybe it is null or something else. // when you got to know that it's an array only then you perform map on it, so following code will compile without error if (Array.isArray(banana)) { let newBanana = banana.map((el: number) => el); console.log("newBanana: ", newBanana); } but if you do it with any, there is no issue and you might endup with null or undefined error.
Guys Assignment jo diya jai.. Comments krke share jarrur krna🎉
Home Works Boolean program
function isDivisibleBy4And8(a: number): boolean {
// return a % 4 ===0 && a%8 ===0;
if (a % 4 === 0 && a % 8 === 0) {
return true;
} else {
return false;
}
}
// fun call
console.log(isDivisibleBy4And8(48));
HomeWorks BigInt
let sum = bigNumber + anotherBigNumber;
console.log(`Sum is ${sum}`);
let difference = bigNumber - anotherBigNumber;
console.log(`Difference is ${difference}`);
let product = bigNumber * anotherBigNumber;
console.log(`Product is ${product}`);
let division = bigNumber / anotherBigNumber;
console.log(`Division is ${division}`);
Answer : ->
[
Sum is 99079191802150916
Difference is -81064793292668934
Product is 811296384146066771921893777735675
Division is 0
]
Bro video ma CHOTI so chez ko itna lamba na kia kro jaldi samghaya kro ❤❤ otherwise love you ❤❤
l
et sum = bigNumber+anotherBigNumber
console.log(sum)
let difference = anotherBigNumber-bigNumber
console.log(difference)
let product = bigNumber*anotherBigNumber
console.log(product)
let division = anotherBigNumber/bigNumber
console.log(division)
bohat vip course ha brother thanks for hardworks and efforts. JAZAKALLAH
type safety and type checking is helpful so use unknown above the any it has better advantage and also get the idea of type when we assign value
we learned in this video about the any type and unknown type . ant type used for the type where we do not assign any type but still want to perform operation its like simple js. but it is not a good way to add cause it is not checcking type and stype safety we compromise. so for that we have unknows type to help in that . we could use unknown type and get the type safety and type checking to perfoe=rm some operation like if (type of a=== boolean) to check the type and if we talk about the type safety we could perfom methods for that type it is available or not .
Awesome
Superb!
Badiya h
🎉
acha hai
Best teacher. Best tutorial ❤
vedio pasand aaya isiliye like karenge hum.
Its Usefull
Great!
Good content 🔥
nice series
Hi Sir Please make a video for your vs studio code. We also want vs studio code like yours.
Great tutorial ...
RUclips per typescript + react js k projects bht kam he please make some!
Thapa sir react js or type script k sth kch projects bh banai please
nice video
nice
Also if we use any then sonar will throw major issue bcoz by default type is any only so there is no usage of typescript if we are using any.
True
Cool, I am in Bootcamp but you are always awesome
♥💙
yes we want the video
Mast laga bhaiya ❤❤
Bro the example you said type checking is also possible with any bro
Frome wher we can get the source code link for definition and questions?
what extension used for This fancy code
❤❤❤
Bahut acha LAG RAHA HAI BHAIYA PADHNE ME BAS AISE HI PADHATE JAO BHAIYA TYPESCRIPT ME VIDEOS KITNI AAYEGI ?
Thank you so much sir.
videos are in reverse order like video number 6 is on order number 1, please correct it.
5:45 but you didn’t declare your variable myFavNum1 with type unknown.
You have not wrote let myFavNum1:unknown =55
When this series is going to be completed?
20days
parhatai easy cheezai ho aur assignment pta nhi kya dai daitai ho, jo assignment daitai ho next video mai uska solution bhi share kr diya krai ap
bro typescript ka source code khareedna h please provide link ?
which theme is this . vscode
haa dekhana chahenge
mera bigint ka output nahi aa raha.
let a= 8%4===0
console.log(a);
plz sir
First comment
Next 13 ki series aayegi kya
after Mern Ecommerce
program boolean
function isEven(a:number):boolean{
console.log(a);
return a%2==0;
}
let result = isEven(9);
console.log(result);
function isDivisibleBy(number :number):boolean {
console.log(number)
if (number%4==0 && number%8==0){
return true;
}
else{
return false;
}
}
console.log(isDivisibleBy(16));
console.log(isDivisibleBy(32));
console.log(isDivisibleBy(20));
console.log(isDivisibleBy(7));
@ThapaTechnical Please share how to fix bigint issue error on running tsc command
If else statement completely wrong
It is perfectly correct Bhai.
But may I know what is wrong in that?
@@ThapaTechnical he just do that for your replay he is big fan of you like we are
Hy brother 🖐
I don't understand use of unknown kindly explain it in detail u use unknown in async await function like
async function fetchDtaa(): Promise
but we all know that async function always return a promise so why u use unknown
and we can also check type of and we can also check type of any like
let fav: any = 12;
fav = true;
console.log(typeof fav);
so why we use unknown
please explain
Even i didnt get the same thing
I still have doubt regarding this “any vs unknown”, but the promise thing, I know that. We know the function will return promise but what type of value will promise return when resolved, so we use that in angular brackets such as . Let say there is a function which is used to get user’s address by using an api. So we can declare function as : function getUserAddress(userId:number) : Promise { … }
Now if we use await,
const addr:string = await getUserAdrress(10);
This will work and typescript will know the datatype of resolved value.
If you try to do something like,
const result:number = await getUserAddress(5);
Typescript will give error because you mentioned that promise will resolve to a string value, but you storing the result in a variable of type number
Also now i got the main difference between any and unknown. Just googled this,
If you use following:
let n:any = 7;
n = n.toUpperCase();
This will not give any compile time error, but if you use following
let a:unknown = 10
console.log(a.toUpperCase())
It will give compile time error, and force you to use type checking i.e
let a:unknown = 10
if ( typeof a === “string”) {
console.log(a.toUpperCase())
}
Hope you get this
Here is an Example
// this is any
let apple: any = 12;
apple = "hello";
apple = true;
apple = 12312312;
let newApple = apple + 12; // we can do it. it will work
let banana: unknown = [1, 2, 3, 4, 5]; // currently for example, it is coming from api, which is unknown to us
// let newBanana = banana.map((el:number) => el); // if we try to map directly, it will wont let you compile. because maybe it is null or something else.
// when you got to know that it's an array only then you perform map on it, so following code will compile without error
if (Array.isArray(banana)) {
let newBanana = banana.map((el: number) => el);
console.log("newBanana: ", newBanana);
}
but if you do it with any, there is no issue and you might endup with null or undefined error.
Thapa sir react js or type script k sth kch projects bh banai please
RUclips per typescript + react js k projects bht kam he please make some!
ruclips.net/video/6ZmszXar1m0/видео.html
watch this.
RUclips per typescript + react js k projects bht kam he please make some!
Thapa sir react js or type script k sth kch projects bh banai please