thank u so much but i did change it a quiet little bit to Fits my needs like this
"use strict";
let _object = {
id: 'SD-10',
location: 'Sv',
addr: '123 str',
// getSetGen: () => {
// }
};
function log([...param]) {
var v = param.map(x => console.log(x))
}
function getPropertyFromGetterSetter(property) {
const sliced = property.slice(3);
const firstLetter = sliced[0].toLowerCase();
const rest = sliced.slice(1);
return firstLetter + rest;
}
// علشان تحدد اذا كان ال Moethod
//هتكون getter ولا setter
const withGettersSetters = {
get(object, property) {
// "getConstructionYear"
if (property.startsWith("get")) {
// getSetGen.get x , y , z ()
return () => object[getPropertyFromGetterSetter(property)];
}
if (property.startsWith("set")) {
// getSetGen.set y , x ,z(value)
return (newValue) => {
object[getPropertyFromGetterSetter(property)] = newValue;
};
}
// getSetGen. x , y , z
return object[property];
}
};
class GettersSetters {
constructor() {
return new Proxy(this, withGettersSetters);
}
}
class getSetGen extends GettersSetters {
constructor([obj , ...params]) {
super();
params = [...params]
var that = this;
var objectKeys = Object.keys(obj);
var param = params.map(x => x)
objectKeys.forEach((el, index) => {
that.el === param[index]
});
}
}
const GetSetGen = new getSetGen([_object , 'SD-v12e', 'Street sw2', 2020]);
console.log(GetSetGen.getId()); // undefined
the main proplem it here objectKeys.forEach((el, index) => {
that.el =param[index]});
i think all i need ti do here's i want to loop throw object propeties and use it and as u see from my params i send the values and loop throw it ans evently i need to
to make equality between them like here
that.el = param[index]
but i all got undefined
console.log(GetSetGen.getId()); // undefined
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
thank u so much but i did change it a quiet little bit to Fits my needs like this
"use strict";
the main proplem it here objectKeys.forEach((el, index) => {
that.el =param[index]});
i think all i need ti do here's i want to loop throw object propeties and use it and as u see from my params i send the values and loop throw it ans evently i need to
to make equality between them like here
that.el = param[index]
but i all got undefined
console.log(GetSetGen.getId()); // undefined