Création d'un objet JS

by toubia95

JavaScript

/*
gjs = new Object();
gjs.CeNombre = function (x) {
    return x*2;
}
*/
gjs = {
    coef2: 2,
    coef3: 3,
    CeNombre: function (x) {
        return x * this.coef2;
    },
    AutreNombre: function (x) {
        return x * this.coef3;
    },
    EncoreNombre: function (x) {
        return this.CeNombre(x) * this.AutreNombre(x);
    }
};

console.log(gjs.CeNombre(2));
console.log(gjs.AutreNombre(2));
console.log(gjs.EncoreNombre(2));