builtInApplyTarget.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function foo(arr)
  6. {
  7. WScript.Echo(Math.min.apply(Math, arr));
  8. WScript.Echo(Math.max.apply(Math, arr));
  9. WScript.Echo();
  10. }
  11. var arr = [{}, 3, 3.4, , new Array()];
  12. var intArr = [1,2,3,4,5];
  13. var floatArr = [1.2,2.3,3.4,4.5,5.6];
  14. foo(arr);
  15. foo(arr);
  16. WScript.Echo("Testing int array");
  17. foo(intArr);
  18. //missing value
  19. len = intArr.length;
  20. intArr[len+1] = 0;
  21. foo(intArr);
  22. intArr.length = len;
  23. //converting to float array
  24. intArr[3] = 0.5;
  25. foo(intArr);
  26. //with a NaN element
  27. intArr.push(Number.NaN);
  28. foo(intArr);
  29. WScript.Echo("Testing float array");
  30. foo(floatArr);
  31. //missing value
  32. len = floatArr.length;
  33. floatArr[len+1] = 0.45;
  34. foo(floatArr);
  35. floatArr.length = len;
  36. floatArr.push(0.5);
  37. foo(floatArr);
  38. //with undefined (will convert the array)
  39. floatArr.push(undefined);
  40. foo(floatArr);