Skip to content

Instantly share code, notes, and snippets.

@Closer2U
Last active October 19, 2020 13:37
Show Gist options
  • Save Closer2U/6222aa6781494ff3a81adb455f060cdb to your computer and use it in GitHub Desktop.
Save Closer2U/6222aa6781494ff3a81adb455f060cdb to your computer and use it in GitHub Desktop.
javascript oop example
<!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>
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