forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharCodeAt.js
More file actions
41 lines (31 loc) · 1.21 KB
/
charCodeAt.js
File metadata and controls
41 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function write(v) { WScript.Echo(v + ""); }
function allChars(s, len) {
write("AllChars : " + s + ". Length : " + len);
for (var i=0; i<len; ++i) {
write(s.charCodeAt(i));
}
}
function firstChar(obj, showOutput) {
if (showOutput != false)
write(">> FirstChar : " + obj);
try {
write(String.prototype.charCodeAt.call(obj, 0));
} catch (e) {
write("Got a exception. " + e.message);
return;
}
if (showOutput != false)
write("<< FirstChar.");
}
allChars("Hello", 5);
allChars("Hello" + "World", 10);
var objs = [ /*null,*/ undefined, 0, 1.1, new Number(10), new String("Hello"),
true, false, new Boolean(true), new Object() ];
firstChar(null, false);
for (var i=0; i<objs.length; ++i) {
firstChar(objs[i]);
}