How is the privileged method of closures implemented in js?

The

completion factory function meets the following requirements
saves the passed parameter name to a private variable
function returns an object, and the object has a privileged method getName, to return the value of the object"s private variable name
as follows:

var person = createPerson("Jero");
console.log("person.name);  //underfind
console.log("person.getName());  //Jero

I just started to learn the concept of closure, but I don"t quite understand the concept of privileged methods, so how can this be implemented to match the output of the two console.log above?
Thank you!

Mar.12,2021

function createPersonname{
  return {
    getName:function(){
      return name
    }
  }
}

right solution upstairs.

it is suggested that the subject should not pursue the answer to this question. It will be easy to read the concept of closure several times, understand it, do a few exercises, and then solve the problem.


function createPerson (name) {

    // name 
    var privateName = name;
    return {
        // name 
        getName : function getName(){
        return privateName;
        }
    }
}
var person = createPerson('Jero');
console.log(person.name); //undefined 
console.log(person.getName());//Jero
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38821-2c111.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38821-2c111.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?