Help please!my code is crashed
weād love to help, but we need a bit more information. Preferably including a link to your codepen or a copy/paste of your code.
1 Like
What object? What is the language you are using? Java: add āprivateā in front of declaration of the field you want to make private. Example : private String privateString = āthis is privateā; . For javascript it will be a bit tricky. You might have to wrap it in something like a function. function stuffInsideIsPrivate(){var thisIsPrivate = āprivateā;};.
You can do like this to make it private;
let obj = function() {
let p = āI am private variableā;
return {
getPrivate: () => {
console.logĀ§;
}
};
}();
obj.getPrivate();