To declare a float array in TypeScript, you can use array literal notation or the Array constructor.
In this example,
floatArray
with predefined values using array literal notation.let floatArray: number[] = [1.2, 3.4, 5.6];
console.log('Float Array:', floatArray);
Float Array: [ 1.2, 3.4, 5.6 ]
In this example,
emptyFloatArray
using the Array constructor without any elements.let emptyFloatArray: number[] = new Array();
console.log('Empty Float Array:', emptyFloatArray);
Empty Float Array: []
In this tutorial, we learned How to Declare a Float Array in TypeScript language with well detailed examples.