Computer scienceProgramming languagesTypeScriptIntroduction to TypeScript

Why we want TypeScript?

Incorrect argument types

Report a typo

The JSDoc format describes the types of function arguments and return values. When calling the function, correct the types of arguments according to the types specified.

Write a program in JavaScript
//@ts-check

/**
* @param {string} arr1
* @param {boolean} arr2
* @param {number[]} arr3
* @returns {string}
*/
function clutter(arr1, arr2, arr3) {
let result = arr1 + arr2 + arr3[0]
return result
}

console.log(clutter(1, 1, ["9", -2]))

Create a free account to access the full topic