The RuntimeObject function is used to search a global object for properties with names that match a specified pattern. The function only locates properties of the global object that were explicitly created by VariableStatement or FunctionDeclaration functions, or that were implicitly created by appearing as an identifier on the left side of an assignment operator. The function does not locate properties that were created by means of explicit property access on the global object.
When the RuntimeObject function is called, the following steps are taken:
1. If pattern is present, set name to "*" and go to step 6.
2. Call the function toPrimitive(pattern, hint Number).
3. If the type of Result(2) is not String, raise a TypeError exception.
4. If Result(2) is the empty string, set name to "*" and go to step 6.
5. Set name = pattern.
6. Set the values of both leftWild and rightWild to false.
7. If the first character of name is "*", let leftWild be true, and remove the first character from name.
8. If the last character of name is "*", let rightWild be true, and remove the last character from name.
9. Let obj
be a new ECMAScript object created as if by the expression
new Object(), where Object is the original built-in
constructor with that name.
10. Let enum be an enumeration of the names of the properties of the global object.
11. Let n be the next element of enum. If there are no more elements, return obj.
12. If n is the name of a built-in property defined by [ECMA-262-1999] Section 15.1, or by the implementation or the host environment, go to step 11.
13. If n was not created by variable instantiation ([ECMA-262-1999] Section 10.1.3), or by an assignment operator in which the left side was the identifier n, go to step 11.
14. If name is the empty string, go to step 19.
15. Search for the first substring name within n, and let left be the position within n of the first character of the matched substring, and let right be the position within n of the last character of the matched substring.
16. If a substring match was not found, go to step 11.
17. If leftWild is false and left is not 1, go to step 11.
18. If rightWild is false and right is not the last character position of n, go to step 11.
19. Let value be the result of calling the [[Get]] property of the global object, passing n as the argument.
20. If value is undefined, go to step 11.
21. Call the [[Put]] method of obj, passing n and value as arguments.
22. Go to step 11.
The length property of the RuntimeObject function has a value of 1.