Object Inside Object in JS

Object Inside Object in JS

<script>

let user = {

        name: “Shairy”,

        sizes: {

          height: 182,

          width: 50,

        },

        getData: function () {

          alert(“hello”);

        },

        showData() {

          alert(this.name + this.sizes.height);

        },

      };

      user.getData();

      user.showData();

      alert(user.sizes.width);

</script>

One thought on “Object Inside Object in JS

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*