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 = {}; console.log(keys(a));
Error:
Uncaught ReferenceError: keys is not defined
What’s going on here? How can I use the keys
function in an included script?
Advertisement
Answer
console.log(keys(a))
keys()
is not function provided by the browser for use in your code. You probably want Object.keys()
a = {}; console.log(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.