Html
<body>
<!-- my script -->
<script>
class Book {
constructor() {
this.myProps = {name: "Walking near sea", price :20};
}
}
var b = new Book();
const {name, total, price} = b.myProps;
alert(name);
// name = "Walking near sea"
alert(total);
// total = undefined
alert(price);
// price = 20
</script>
</body>
Html
<!-- my script -->
<script>
class Book {
constructor() {
this.name = "Walking near sea";
this.price = 20;
}
}
var b = new Book();
const {name, total, price} = b;
// name = "Walking near sea"
// total = undefined
// price = 20
</script>
Html
<body>
<!-- my script -->
<script>
class Book {
constructor() {
this.myProps = {name: "Walking near sea", price :20};
}
DoSomething()
{
const {name, total, price} = this.myProps;
// name = "Walking near sea"
// total = undefined
// price = 20
}
}
var b = new Book();
b.DoSomething();
</script>
</body>