Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:46:17+00:00 2026-06-12T10:46:17+00:00

While I was testing saw a behavior of console(Chrome). if i type console.log({key:’value’}) is

  • 0

While I was testing saw a behavior of console(Chrome). if i type console.log({key:'value'}) is printing Object {key: "value"} which was expected by me. But when I directly typed {key:'value'} in console it printing 'value' only while I expected Object {key: "value"}.

Saw same behavior in IE10 and FF.
What is the reason behind this behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:46:18+00:00Added an answer on June 12, 2026 at 10:46 am

    It’s because your object is instead being interpreted as a block statement with a single statement within consisting of a string literal preceded by a label.

    //  v---block----v
        {key: "value"}
    //    ^--label 
    

    For the console to interpret it as object literal syntax, it needs to be part of an expression. If you wrap in parens, you’ll get the expected result.

    ({key:"value"})
    

    Side note:

    Here’s the really weird part. A statement is a statement because it doesn’t return anything. So why does it return "value"?

    In JavaScript, statements have something like a final value. (I don’t remember exactly what it’s called.) It isn’t anything that’s useful or reachable in program code, but when a program is evaluated, that final value will be returned to whatever evaluated it.

    The same goes when you use eval() to evaluate a program. Its final statement value will be returned. Since code in a console is eval‘d, it gets that final value and prints it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the NSConcreteData leaked object while testing the leaks in the instruments.It
While testing my Google App Engine application, I search for links which include app
While testing my in-app-purchases, I am receiving these in my console for both attached
While testing some real-time simulation code which uses a Swingworker I noticed my GUI
i have a Problem while testing my DAOObject. I have two Entitys which are
While testing my web app, I'd like to be able to set the value
While testing some HTTP server code, I noticed something odd: if I return Content-Type:
I'm just experiencing weird behavior while testing an Goliath API with RSpec. One of
While testing a console app, I set the properties of the console window to
i'm facing a issue while testing the DAL Library which uses LINQ to SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.