Constructor appends a method in the specified object,

a ={
  x:function(){console.log(1)}
}
function B(){
 this.y = function(){}
}

think var b = new B ();

b = {
 x:...,
 y:....
}

how to implement

Mar.23,2021

Add a step before

new to attach the method in object a to the prototype of B.

Object.keys(a).forEach(function(v) {
    B.prototype[v] = a[v]
})
var b = new B()

you can also copy the methods in object a directly into b after new (of course, this may overwrite the methods in the constructor

var b = new B()
Object.keys(a).forEach(function(v) {
    b[v] = a[v]
})

if you just want to simply put a.x into b, the simplest thing is b.x = a.x. Since you didn't mention the specific needs, you might as well refer to the boss upstairs.

Menu