-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjectjs.html
More file actions
32 lines (31 loc) · 755 Bytes
/
objectjs.html
File metadata and controls
32 lines (31 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<html>
<head>
<script type="text/javascript">
function cars(car_model,car_brand,car_price)//obj coreation using constructor
{
this.car_model=car_model;//this keyword is use to refer to the current variable
this.car_brand=car_brand;
this.car_price=car_price;
this.teslautopilot=function()
{
document.write("auto pilot feature");
}
}
var c1=new cars("1","tesla",35000);//here c1 is name of the object
document.write(c1.car_model+c1.car_brand+c1.car_price);
c1.fuel="petrol";//we can add another variable to the constructor outside also
document.write(c1.fuel);
//var str1=new String();
/*function s()
{
}
var stri="sad";
var i=2;
document.write(typeof(s));
document.write(typeof(stri));
document.write(typeof(i));*/
</script>
</head>
<body>
</body>
</html>