{"size": 880, "ext": "js", "max_stars_repo_path": "Dicoding - JS Dasar/Struktur Data/weakMap.js", "max_stars_repo_name": "urbanSnowbay/Belajar-Dasar-Pemrograman-Javascript-Dicoding", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Dicoding - JS Dasar/Struktur Data/weakMap.js", "max_issues_repo_name": "urbanSnowbay/Belajar-Dasar-Pemrograman-Javascript-Dicoding", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Dicoding - JS Dasar/Struktur Data/weakMap.js", "max_forks_repo_name": "urbanSnowbay/Belajar-Dasar-Pemrograman-Javascript-Dicoding", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.7837837838, "max_line_length": 64, "alphanum_fraction": 0.5806818182}
// Map
let visitsCountMap = new Map(); // Menyimpan daftar user
 
function countUser(user) {
    let count = visitsCountMap.get(user) || 0;
    visitsCountMap.set(user, count + 1);
}
 
let jonas = { name: "Jonas" };
countUser(jonas);                // Menambahkan user "Jonas"
 
jonas = null;                    // Data object "Jonas" dihapus
 
console.log(visitsCountMap);
 
/* output
Map(1) { { name: 'Jonas' } => 1 }
*/

// Weak Map
let visitsCountMap = new WeakMap(); // Menyimpan daftar user

function countUser(user) {
    let count = visitsCountMap.get(user) || 0;
    visitsCountMap.set(user, count + 1);
}

let jonas = { name: "Jonas" };
countUser(jonas);                // Menambahkan user "Jonas"

jonas = null;                    // Data object "Jonas" dihapus

console.log(visitsCountMap);

/* output
WeakMap { <items unknown> }
*/