How prototype inheritance can affect method overriding in JavaScript?

Here’s the code,

            function extend(child, parent){
				child.prototype = Object.create(parent.prototype);
				child.prototype.constructor = child
			}
			
			
			//Super Class
			var Mobile = function(){
			
			}
			//Prototype Method
			Mobile.prototype.show = function(){
				return "Super Class Method";
			}
			//Sub class 
			var Samsung = function(){
				
			}
            // 1. 
			// extend(Samsung, Mobile); //displays "Sub Class Method"
			Samsung.prototype.show = function(){
				return "Sub Class Method";
			}
            //2.
			// extend(Samsung, Mobile); //displays "Super Class Method"
			var sam = new Samsung();
			document.write(sam.show());

When I extend Samsung.prototype with Mobile.prototype before initializing the prototype method show() for Samsung, I get to see the show() method of Samsung.prototype, But writing it after initialization provides me with show() method of Mobile.prototype. Could someone please explain what’s happening in the background?