DEV Community

Cover image for What will be the Output? | JavaScript
Nitish Kumar Singh
Nitish Kumar Singh

Posted on

3 1

What will be the Output? | JavaScript

I have a program and that is a little bit insane.

This is the program and I wanted to know how many of you already know this concept.


    var boy = {
            name:"Natasha",
            birthday : {
                date : 1,
                month : 'April',                    
            }   
        }

    var girl = { ...boy } ;  // copying object

    boy.name = 'Nitish' ;  
    boy.birthday.date = 31 ;
    boy.birthday.month = "December" ;

   console.log(boy) ;

   console.log(girl);  

These types of question are usually asked in the interview.

Comment you answer

For more question like this follow me

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)