ecmascript 6 - typesafe rest parameter in ES6 -
do have way make rest parameter typesafe. trying following code throwing error,
<script> function addn(name, ...numarray:number[]){ let result = 0; numarray.foreach((n) => result += n); return result; } document.write(addn('abc', 2,33,6)); </script>
Comments
Post a Comment