Destructuring Object tutorial in Advance JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Destructuring Object Advance JavaScript</title>
<link rel="stylesheet" href="">
</head>
<body>
<script>
let user = {
name: "Hello World",
age: 25,
city: "Ahmedabad"
};
let { name, age, city } = user;
console.log(name);
console.log(age);
console.log(city);
//We can use Alias Name(For Example: For name, we use Alias Name "n", For age, we use Alias Name "a", For city, we use Alias Name "c") as shown below :
let { name: n, age: a, city: c } = user;
console.log(n);
console.log(a);
console.log(c);
</script>
</body>
.png)
.png)
Comments
Post a Comment