Constructing a JavaScript Array prototype method <p>I am new to constructing a JavaScript Array prototype. Please only paste previous links that are directly appropriate as I have been sourcing on SO and on w3school. <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype" rel="nofollow">https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype</a></p> <p>I would like to create a method for an array that checks if the 'id' field within the object does not already exist in the array. If not, then 'push' object into the array, else do nothing.</p> <p>Each object has a unique 'id' field.</p> <pre><code>eg var array = [{ id: 001, title: 'some title'}, { id: 002, title: 'other title'}] var object = {id: 001, title: 'some title'} // if object.id does not exist in array... array.push(object) //else do nothing </code></pre> <p>I would like the function to take the 'id' field as an argument so this function has wider use.</p> <p>Are there any drawbacks to extending the array.Prototype? Otherwise I can do a for loop instead to do the check without the prototype constructor.</p>