Author: ShairyPortfolio
-

Getter Setter method in ES6
<script> let user = { name: “Etude”, surname: “pro”, get fullName() { return this.name + ” ” + this.surname; }, set fullName(value) { [this.name, this.surname] = value.split(” “); }, set fullName1(obj) { this.name = obj.firstName; this.surname = obj.lastName; }, }; …
-

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>
-

Perform Different operation in objects
<script> let demo={ name:”shairy”, age:30, “last name”:”kalra” } alert(demo.name); demo.result=”pass”; alert(demo.result); delete demo.age; alert(demo.age); demo.name=”abhi”; alert(demo.name); alert(demo[“last name”]); delete demo[“last name”]; alert(demo[“last name”]); let abc = prompt(“What do you want to know about the user?”, “last name”); alert(…
-

Object in JS
Object is the most important data-type for modern JavaScript that contain any combination of data-types in the form of “key: value” pairs. These keys can be variables or functions in the term of an object that can be created with curly brackets {…} <script> const person={ name:’shairy’, designation:[‘professor’,’Developer’], working:function(){ …