Hi dear welcome to "CodePrime" Blog . In this post You are going to learn How to use object Data Type in javascript. First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat object.js file Then Copy The JS CODE and pest it. next connect the object.js file with index.html. then open the index.html file with your browser.
HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/js/object.js"></script>
<title>premitive data type</title>
</head>
<body>
<h2>Javascript Tutorial</h2>
<h3>By Codeprime</h3>
</body>
</html>
JAVASCRIPT CODE
let shirt={
type:'T-Shirt',
color:'black',
cost:40,
};
console.log(shirt);
//objectname.propertyname
//objectname['propertyname']
console.log(shirt.cost);
//example
let AbdullahSheikh={
age:22,
university:'University Of People',
semister:'3rd',
subject:['physics','math','ict','english']
};
console.log(AbdullahSheikh.subject[0]);
0 Comments