JSFiddle - React, Tailwind, and code Playground
by hicurin
JavaScript
/* Create an object class */
var obj = function(){ this.attributes = new Array(); }
obj.prototype.addProp = function(value){ this.attributes.push(new attribute(value)); }
obj.prototype.hasProp = function(value){
for(var i = 0; i < this.attributes.length; i++){
if(value == this.attributes[i].value) return true; } return false; }
function attribute(value){
this.value = value;
}
/* Testing object has some value*/
var ob = new obj();
ob.addProp('1');
ob.addProp('2');
ob.addProp('3');
//* check value index
//alert(ob.attributes[0].value);
//* check if ob has prop
alert(ob.hasProp('1'));