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 2081 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)
developer avatar
Spelling / formatting error
Benoit
17/09/2024
plus personne ne code comme ça depuis 10 ans