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:
If pattern is present, set name to "*" and go to step 6.
Call the function toPrimitive(pattern, hint Number).
If the type of Result(2) is not String, raise a TypeError exception.
If Result(2) is the empty string, set name to "*" and go to step 6.
Set name = pattern.
Set the values of both leftWild and rightWild to false.
If the first character of name is "*", let leftWild be true, and remove the first character from name.
If the last character of name is "*", let rightWild be true, and remove the last character from name.
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.
Let enum be an enumeration of the names of the properties of the global object.
Let n be the next element of enum. If there are no more elements, return obj.
If n is the name of a built-in property defined by [ECMA-262] Section 15.1, or by the implementation or the host environment, go to step 11.
If n was not created by variable instantiation ([ECMA-262] Section 10.1.3), or by an assignment operator in which the left side was the identifier n, go to step 11.
If name is the empty string, go to step 19.
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.
If a substring match was not found, go to step 11.
If leftWild is false and left is not 1, go to step 11.
If rightWild is false and right is not the last character position of n, go to step 11.
Let value be the result of calling the [[Get]] property of the global object, passing n as the argument.
If value is undefined, go to step 11.
Call the [[Put]] method of obj, passing n and value as arguments.
Go to step 11.
The length property of the RuntimeObject function has a value of 1.