I have a javascript associative array. It will be populated dynamically.
I want to find the keys which will contain the duplicate data/values.
For simplicity, it will look like this.
var p = { };
p =
{
"p1": "value1",
"p2": "value2",
"p3": "value3",
"p4": "value2",
"p5": "value3",
"p6": "value5"
};
How can i do this.
Here's the js fiddle.
Is there other way than using hasOwnProperty?
Any ideas to make this work?
p5keys! The second one will override the first one. It's like it was never even there.hasOwnPropertywon't help you find duplicate values. That checks to see if an object has a certain "key".