Search code examples
jsonkey-valuetypeofgoogle-chrome-console

What is the type of the key in this JSON object {yourVariable: "nothing yet"}


Chrome Developer Console is console.loging this:

Your JSON sent is>> {yourVariable: "nothing yet"}

So i know the value "nothing yet" in the {yourVariable: "nothing yet"} JSON object is a string. But how do I know the type of the key yourVariable?

Is there a way how to find that out using the Chrome console only?


Solution

  • All object keys are strings with quotes or without quotes. Try this way to see it. May be you are confused with console print because console print it without quotes and we usually write with quotes.

    var jsonObj = {person:"me","age":"30", 123:"123"};
    Object.keys(jsonObj).forEach(function(key){
       console.log(typeof key)}
    );