I am learning Javascript and I am a C++ programmer. I have tried creating an object with a constructor with object.create and here is the result:
var PlayGround ={
    initGrid : function(N) {
        this.N=N;
        this.grid = new Array(N);
        for (var i = 0; i < N; i++) {
            this.grid[i] = new Array(N);
            for (var j = 0; j < N; j++) {
                this.grid[i][j] = false;
            }
        }
        return true;
}
};
var PlayGround_property = {
    N:{
        value: 100,
        writable:true
    },
    grid:{
        value:null,
        writable:true
    }
}
var board= Object.create(PlayGround, PlayGround_property);
It works as I want: the object board contains the object grid, and now I can use the set and get keyword to define the behaviour of the = and () operator. Anyway I have read around the web that the
this
keyword in Javascript is not safe and I want to be sure that it is referring always to the board object and not to the global window object. Is there a way or I am overthinking? Other question, are there other ways to write object with a constructor (and maybe other members) in Javascript?
 
    