Last active
October 19, 2020 13:37
-
-
Save Closer2U/6222aa6781494ff3a81adb455f060cdb to your computer and use it in GitHub Desktop.
javascript oop example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
function item (product, price, quantity) { | |
this.product = product | |
this.price = price | |
this.quantity = quantity | |
}; | |
const bread = new item ('bread', 2.50, 1); | |
console.log(bread.product); | |
console.log(bread.price); | |
console.log(bread.quantity); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function item (product, price, quantity) { | |
this.product = product | |
this.price = price | |
this.quantity = quantity | |
}; | |
const bread = new item ('bread', 2.50, 1); | |
console.log(bread.product); | |
console.log(bread.price); | |
console.log(bread.quantity);</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function item (product, price, quantity) { | |
this.product = product | |
this.price = price | |
this.quantity = quantity | |
}; | |
const bread = new item ('bread', 2.50, 1); | |
console.log(bread.product); | |
console.log(bread.price); | |
console.log(bread.quantity); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment