<titledata-rh="true">JSHandle class | Puppeteer</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://pptr.dev/api/puppeteer.jshandle"><metadata-rh="true"property="og:locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docsearch:counter"content="2"><metadata-rh="true"property="og:title"content="JSHandle class | Puppeteer"><metadata-rh="true"name="description"content="Represents a reference to a JavaScript object. Instances can be created using Page.evaluateHandle()."><metadata-rh="true"property="og:description"content="Represents a reference to a JavaScript object. Instances can be created using Page.evaluateHandle()."><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/api/puppeteer.jshandle"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/api/puppeteer.jshandle"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/api/puppeteer.jshandle"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://DVKY664LG7-dsn.algolia.net"crossorigin="anonymous"><linkrel="search"type="application/opensearchdescription+xml"title="Puppeteer"href="/opensearch.xml">
<p>Represents a reference to a JavaScript object. Instances can be created using <ahref="/api/puppeteer.page.evaluatehandle">Page.evaluateHandle()</a>.</p>
<p>Handles prevent the referenced JavaScript object from being garbage-collected unless the handle is purposely <ahref="/api/puppeteer.jshandle.dispose">disposed</a>. JSHandles are auto-disposed when their associated frame is navigated away or the parent context gets destroyed.</p>
<p>Handles can be used as arguments for any evaluation function such as <ahref="/api/puppeteer.page._eval">Page.$eval()</a>, <ahref="/api/puppeteer.page.evaluate">Page.evaluate()</a>, and <ahref="/api/puppeteer.page.evaluatehandle">Page.evaluateHandle()</a>. They are resolved to their referenced object.</p>
<h4class="anchor anchorWithStickyNavbar_FNw8"id="signature">Signature:<ahref="#signature"class="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"></a></h4>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="remarks">Remarks<ahref="#remarks"class="hash-link"aria-label="Direct link to Remarks"title="Direct link to Remarks"></a></h2>
<p>The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the <code>JSHandle</code> class.</p>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="example">Example<ahref="#example"class="hash-link"aria-label="Direct link to Example"title="Direct link to Example"></a></h2>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="properties">Properties<ahref="#properties"class="hash-link"aria-label="Direct link to Properties"title="Direct link to Properties"></a></h2>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="methods">Methods<ahref="#methods"class="hash-link"aria-label="Direct link to Methods"title="Direct link to Methods"></a></h2>
<table><thead><tr><th><p>Method</p></th><th><p>Modifiers</p></th><th><p>Description</p></th></tr></thead><tbody><tr><td><spanid="aselement"><ahref="/api/puppeteer.jshandle.aselement">asElement()</a></span></td><td></td><td><p>Either <code>null</code> or the handle itself if the handle is an instance of <ahref="/api/puppeteer.elementhandle">ElementHandle</a>.</p></td></tr><tr><td><spanid="dispose"><ahref="/api/puppeteer.jshandle.dispose">dispose()</a></span></td><td></td><td><p>Releases the object referenced by the handle for garbage collection.</p></td></tr><tr><td><spanid="evaluate"><ahref="/api/puppeteer.jshandle.evaluate">evaluate(pageFunction, args)</a></span></td><td></td><td><p>Evaluates the given function with the current handle as its first argument.</p></td></tr><tr><td><spanid="evaluatehandle"><ahref="/api/puppeteer.jshandle.evaluatehandle">evaluateHandle(pageFunction, args)</a></span></td><td></td><td><p>Evaluates the given function with the current handle as its first argument.</p></td></tr><tr><td><spanid="getproperties"><ahref="/api/puppeteer.jshandle.getproperties">getProperties()</a></span></td><td></td><td><p>Gets a map of handles representing the properties of the current handle.</p></td></tr><tr><td><spanid="getproperty"><ahref="/api/puppeteer.jshandle.getproperty">getProperty(propertyName)</a></span></td><td></td><td><p>Fetches a single property from the referenced object.</p></td></tr><tr><td><spanid="getproperty"><ahref="/api/puppeteer.jshandle.getproperty_1">getProperty(propertyName)</a></span></td><td></td><td></td></tr><tr><td><spanid="jsonvalue"><ahref="/api/puppeteer.jshandle.jsonvalue">jsonValue()</a></span></td><td></td><td><p>A vanilla object representing the serializable portions of the referenced object.</p><p><strong>Remarks:</strong></p><p>If the object has a <code>toJSON</code> function, it <strong>will not</strong> be called.</p></td></tr><tr><td><spanid="remoteobject"><ahref="/api/puppeteer.jshandle.remoteobject">remoteObject()</a></span></td><td></td><td><p>Provides access to the <ahref="https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-RemoteObject"target="_blank"rel="noopener noreferrer">Protocol.Runtime.RemoteObject</a> backing this handle.</p></td></tr><tr><td><spanid="tostring"><ahref="/api/puppeteer.jshandle.tostring">toString()</a></span></td><td></td><td><p>Returns a string representation of the JSHandle.</p><p><strong>Remarks:</strong></p><p>Useful during debugging.</p></td></tr></tbody></table></div></article><navclass="pagination-nav docusaurus-mt-lg"aria-label="Docs pages"><aclass="pagination-nav__link pagination-nav__link--prev"href="/api/puppeteer.frame.waitforselector"><divclass="pagination-nav__sublabel">Previous</div><divclass="pagination-nav__label">Frame.waitForSelector</div></a><aclass="pagination-nav__link pagination-nav__link--next"href="/api/puppeteer.jshandle.aselement"><divclass="pagination-nav__sublabel">Next</div><divclass="pagination-nav__label">JSHandle.asElement</div></a></nav></div></div><divclass="col col--3"><divclass="tableOfContents_IS5x thin-scrollbar theme-doc-toc-desktop"><ulclass="table-of-contents table-of-contents__left-border"><li><ahref="#remarks"class="table-of-contents__link toc-highlight">Remarks</a></li><li><ahref="#example"class="table-of-contents__link toc-highlight">Example</a></li><li><ahref="#properties"class="table-of-contents__link toc-highlight">Properties</a></li><li><ahref="#methods"class="table-of-contents__link toc-highlight">Methods</a></li></ul></div></div></div></div></main></div></div></div><footerclass="footer footer--dark"><divclass="container container-fluid"><divclass="row footer__links"><divclass="col footer__col"><divclass="footer__title">Community</div><ulclass="footer__items clean-list"><liclass="footer__item"><ahref="https://stackoverflow.com/questions/tagged/puppeteer"target="_blank"rel="noopener noreferrer"class="footer__link-item">Stack Overflow<svgwidth="13.5"height="13.5"aria-hidden="true"viewBox="0 0 24 24"class="iconExternalLi