<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>associative array</title>
</head>
<body>
<script>
searchip = {}; // JSON {} NOT array []
function add_to_serach_ip(ip)
{
if (!(searchip[ip])) searchip[ip] = 1; // not found add
else
console.log("Found.");
}
console.log("Start empty: ");
console.log(searchip);
add_to_serach_ip('abc');
console.log("After adding: ");
console.log(searchip);
console.log("Count of objects: "+Object.keys(searchip).length); // Number of items
add_to_serach_ip('def');
console.log("After adding: ");
console.log(searchip);
console.log("Count of objects: "+Object.keys(searchip).length); // Number of items
delete searchip['abc']; // remove
console.log("After deleting: abc");
console.log(searchip);
</script>
</body>