Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find array object value is already in use

function add(name) {
    var id = arr.length + 1;        
            if (arr.filter(item=> item.username == name).length == 0){
            arr.push({ id: id, username: name });
        }
}
 
PREVIOUS NEXT
Tagged: #find #array #object
ADD COMMENT
Topic
Name
1+1 =