Object oriented JavaScript
JavaScript Oops Example 1
by Rijo R
JavaScript
// JacaScript Does not support classes
var Pizza = {
crust : 'thin', // Public propertiese
toppings : 3,
hasBacon : true,
howmanyToppings : function(){ // Public method
return this.toppings; // So 'this' keyword is used to access public propertiece
}
};
// var Pizza is an object
Pizza.price = '$5'; // Create property after that object creation
console.log(Pizza.howmanyToppings());
console.log(Pizza);
delete(Pizza.crust); // Delete propertiece from objects
console.log(Pizza);