Closed
Description
I have the following code that I have get till page 94 of the first edition:
function Set() {
var items = {};
this.has = function(value) {
return items.hasOwnProperty(value);
}
this.add = function(value){
if(!this.has(value)){
items[value] = value;
return true;
}
return false;
}
}
var set = new Set();
set.add(1);
set.add(5);
set.add(10);
console.log(set.items); //undefined
The console.log
outputs undefined
. I'm using Google Chrome Version 62.0.3202.75 64 bit on Ubuntu linux and my files structure is two files:
- index.html
- js.js