JQuery and ES6 Industrial Training

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>


Comments

One response to “Object Inside Object in JS”

  1. Manpreet Singh Avatar
    Manpreet Singh

    Well explanied

Leave a Reply to Manpreet Singh Cancel reply

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