View the list of all variables in Google Chrome Console using JavaScript Last Updated : 20 Sep, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report All the variables in Google Chrome can be listed for the use of debugging. There are two approaches to list all variables: Method 1: Iterating through properties of the window object: The window object in JavaScript represents the current browser's window. The properties of this object can be used to find the variables of the Chrome browser. Each of the properties of the window object is first checked with the hasOwnProperty() method. This ensures that the object has the property as its own property. Syntax: javascript for (let variable in window) { if (window.hasOwnProperty(variable)) { console.log(variable); } } Example: html <!DOCTYPE html> <html> <head> <title> View the list of all variables in Google Chrome Console in JavaScript </title> </head> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <b> View list of all JavaScript variables in Google Chrome Console </b> <p> Click on the button to view list of all JavaScript variables in the Google Chrome Console </p> <button onclick="findAllVariables()"> Click here </button> <script type="text/javascript"> function findAllVariables() { for (let variable in window) { if (window.hasOwnProperty(variable)) { console.log(variable); } } } </script> </body> </html> Output: Console Output: Method 2: Using the Object.keys() method: The Object.keys() method is used to return the properties of the given object as an array. As the window object represents the current browser's window, the properties of this object can be used to find the variables like the previous method. The Object.keys() method is passed the window object as the parameter to get its keys. Each of the keys in this object represents a variable of the Google Chrome browser. These can then be listed in the console. Syntax: javascript let variables = Object.keys(window); console.log(variables); Example: html <!DOCTYPE html> <html> <head> <title> View the list of all variables in Google Chrome Console in JavaScript </title> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> View list of all JavaScript variables in Google Chrome Console </b> <p> Click on the button to view list of all JavaScript variables in the Google Chrome Console </p> <button onclick="findAllVariables()"> Click here </button> <script type="text/javascript"> function findAllVariables() { let variables = Object.keys(window); console.log(variables); } </script> </body> </html> Output: Console Output: Comment More infoAdvertise with us Next Article How to print debug messages in the Google Chrome JavaScript Console? S sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads How to print debug messages in the Google Chrome JavaScript Console? Printing in the console is pretty easy all we have to know is how to activate the console on the chrome for viewing. The Console is always active all we are doing is making it visible to the front-end. A console is an object which provides access to the browser's debugging console. Console object ha 2 min read Running JavaScript in Console in Microsoft Edge Browser JavaScript is an important programming language that is mainly developed for web use cases and it plays a vital role in improving the responsiveness and usefulness of websites. On the other hand, Microsoft Edge is a web browser that offers a built-in JavaScript engine for development. So here, we'll 3 min read How to list all the cookies of the current page using JavaScript ? Cookies are small pieces of data stored by websites on your browser to remember information about your visit, such as login status, preferences, or other settings. In JavaScript, you can easily retrieve cookies stored by the current domain using document.cookie. However, due to security reasons, you 3 min read How to declare Global Variables in JavaScript ? Global Variables Global variables in JavaScript are variables declared outside of any function. These variables are accessible from anywhere within the script, including inside functions. Global variables are declared at the start of the block(top of the program)Var keyword is used to declare variab 2 min read How to Call a JavaScript Function from Chrome Console ? One can call a JavaScript Function from the Chrome Console. We will learn how can we call the function in the console that is written in JavaScript. Steps to call a JavaScript Function from Chrome ConsoleOpen the Chrome ConsoleYou can open the Chrome Console by right-clicking on your webpage, select 2 min read How to Use Dynamic Variable Names in JavaScript? Dynamic variable names are variable names that are not predefined but are generated dynamically during the execution of a program. This means the name of a variable can be determined at runtime, rather than being explicitly written in the code.Here are different ways to use dynamic variables in Java 2 min read Like