First of all, you are doing some things wrong here. Let me break it down. See the comments after each line.
function test(){
var a = 1; //this variable a is local to this function test only.so it is not part of the o1,o2 objects.
this.b =2; //this keyword refers to the object on which this function is called.
}
var o1 = new test();
var o2 = Object.create(test);//this is not a way to create object using Object.create().. Object.create() takes another object as an argument to create a new object and here you are using test which is a function.
console.log(test.a); //test is a function not an object
console.log(test.b); //test is a function not an object
console.log(o1.a); //since a is local to the function that's why you are getting undefined here
console.log(o1.b); //here output is 2 because b is an object property and you have assigned its value to 2 in the test function.
console.log(o2.a); //undefined because o2 is not an object it is a function.
console.log(o2.b); //undefined because o2 is not an object it is a function.
You can try to implement the above code in this way:
var Test=function test(){
this.a = 1;
this.b =2;
}
var o1 = new Test();
var o2 = Object.create(o1);
console.log(o1.a);
console.log(o1.b);
console.log(o2.a);
console.log(o2.b);