website/versioned_docs/version-24.40.0/api/puppeteer.jshandle.md
Represents a reference to a JavaScript object. Instances can be created using Page.evaluateHandle().
Handles prevent the referenced JavaScript object from being garbage-collected unless the handle is purposely disposed. JSHandles are auto-disposed when their associated frame is navigated away or the parent context gets destroyed.
Handles can be used as arguments for any evaluation function such as Page.$eval(), Page.evaluate(), and Page.evaluateHandle(). They are resolved to their referenced object.
export declare abstract class JSHandle<T = unknown>
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the JSHandle class.
const windowHandle = await page.evaluateHandle(() => window);
Property
</th><th>Modifiers
</th><th>Type
</th><th>Description
</th></tr></thead> <tbody><tr><td><span id="_">_</span>
</td><td>optional
T
</td><td>Used for nominally typing JSHandle.
</td></tr> <tr><td><span id="move">move</span>
</td><td> </td><td>() => this
</td><td> </td></tr> </tbody></table>Method
</th><th>Modifiers
</th><th>Description
</th></tr></thead> <tbody><tr><td><span id="aselement">asElement()</span>
</td><td> </td><td>Either null or the handle itself if the handle is an instance of ElementHandle.
<span id="dispose">dispose()</span>
</td><td> </td><td>Releases the object referenced by the handle for garbage collection.
</td></tr> <tr><td><span id="evaluate">evaluate(pageFunction, args)</span>
</td><td> </td><td>Evaluates the given function with the current handle as its first argument.
</td></tr> <tr><td><span id="evaluatehandle">evaluateHandle(pageFunction, args)</span>
</td><td> </td><td>Evaluates the given function with the current handle as its first argument.
</td></tr> <tr><td><span id="getproperties">getProperties()</span>
</td><td> </td><td>Gets a map of handles representing the properties of the current handle.
</td></tr> <tr><td><span id="getproperty">getProperty(propertyName)</span>
</td><td> </td><td>Fetches a single property from the referenced object.
</td></tr> <tr><td><span id="getproperty">getProperty(propertyName)</span>
</td><td> </td><td> </td></tr> <tr><td><span id="jsonvalue">jsonValue()</span>
</td><td> </td><td>A vanilla object representing the serializable portions of the referenced object.
Remarks:
If the object has a toJSON function, it will not be called.
<span id="remoteobject">remoteObject()</span>
</td><td> </td><td>Provides access to the Protocol.Runtime.RemoteObject backing this handle.
</td></tr> <tr><td><span id="tostring">toString()</span>
</td><td> </td><td>Returns a string representation of the JSHandle.
Remarks:
Useful during debugging.
</td></tr> </tbody></table>