Question from the Javascript test

How to call a function inside a function in Javascript

Hard

Considering the following code:

function MyObject(){
  this.one = function(){
    return 1;
  };
  function two(){
    return 2;
  };
}

MyObject.prototype.three= 3;
MyObject.four= 4;

var obj = new MyObject();
try{ console.log(obj.one()); } catch(e){}
try{ console.log(obj.two()); } catch(e){}
try{ console.log(obj.three); } catch(e){}
try{ console.log(obj.four); } catch(e){}
Author: Jean-marie CléryStatus: PublishedQuestion passed 2144 times
Edit
4
Community EvaluationsNo one has reviewed this question yet, be the first!