TypeScript Hindi Tutorial #17 Function Params Type in TypeScript
Function Params Type
functionParams.js
"use strict";
function totalPrice(item, price, text) {
var price = 100;
if (text) {
console.log(text + price * item);
}
else {
console.log(price * item);
}
}
// totalPrice(20,200
// ,"total amount is ");
// totalPrice(20,200);
// function simple(data:string| number | boolean){
// console.log(data)
// }
function simple10(data) {
console.log(data);
}
simple10("anil sidhu");
functionParams.ts
function totalPrice(item: number, price: number, text?: string): void {
const priceValue: number = 100;
if (text) {
console.log(text + priceValue * item);
} else {
console.log(priceValue * item);
}
}
function simple10(data: string | number | boolean): void {
console.log(data);
}
simple10("anil sidhu");