Skip to content

javascript – Uncaught ReferenceError: keys is not defined

I am getting an error when I run the following command in an included script. But if I run the command from the google chrome console, it works properly.

var a = {};


 Uncaught ReferenceError: keys is not defined

What’s going on here? How can I use the keys function in an included script?



keys() is not function provided by the browser for use in your code. You probably want Object.keys()

a = {};

Sometimes the console has extra functions exposed to it for ease of use debugging that aren’t available in your actual code. keys() sounds like one, and copy('some text') is another.

I’m failing to find a link which lists them, sadly. But I’m quite sure there are more than those 2 functions.