Having trouble accessing a keyvalue pair inside an JS object, getting the following error in chrome:
Uncaught TypeError: undefined is not a function jQuery.event.dispatch jquery-2.1.0.js:4371 jQuery.event.add.elemData.handle
So, here is my code:
//Separate file named Product.js
function Product() {
var field = {
ProductName: "False Teeth",
SupplierID: 7,
}
this.init = function () {
//any initialisation code
}
var getProperty = function (propertyName) {
return field[propertyName];
}
};
//In another javascript file, trying to access the object
var product = new Product();
//THIS GIVES THE ERROR undefined is not a function
console.log("supplierID:" + product.getProperty("SupplierID"));
Any ideas?