JS prototype call problem

  node.js, question
function A() {
 getName = function (argument) {
 alert(1);
 bracket
 bracket
 
 A.prototype.getName = function (argument) {
 alert(2);
 bracket
 
 new A().getName();

Why is the display 2? ? Didn’t you call the getName method in the a function? ? ? How to write if you want to call the first one?

function A() {
 this.getName = function (argument) {
 alert(1);
 bracket
 bracket

You assigned getName to the global object without this. So the new A () object itself does not have getName.