Make Object Properties Private

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: () => {