StringCharCodeAt.js 628 B

123456789101112131415161718192021222324
  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 test(s, i)
  6. {
  7. var ch = s.charCodeAt(i);
  8. WScript.Echo(ch);
  9. }
  10. var s = "Hello";
  11. // Valid range
  12. test(s, 0);
  13. test(s, 1);
  14. // Invalid range
  15. test(s, -1);
  16. test(s, 10);
  17. // position.ToInteger()
  18. test(s, 2.32);
  19. test(s, Math.PI);