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 1994 times
Edit
4
Community Evaluations
developer avatar
Quang
23/03/2023
On demande ici comment accéder aux propriétés d'un objet (Object.prop)