UpTest > Web Development > Meteor Test

Test: Meteor Test

Question 1: Prev Next Hide answers

How to get this.userId in function inside Meteor method?

myMethod: function () {
  var userId = this.userId;
  console.log(this.userId); 
  function innerFunction(userId) {
      console.log(userId);
  innerFunction();
}
1 votes
All of the above
0 votes
myMethod: function () {
    var that = this;
    console.log(this.userId); 
    function innerFunction() {
       console.log(that.userId);
    }
    innerFunction();
}
0 votes
myMethod: function () {
 console.log(this.userId); 
 function innerFunction() {
     console.log(this.userId);
 };
 innerFunction.apply(this);
}
0 votes
myMethod: function () {
 console.log(this.userId); 
 function innerFunction() {
     console.log(this.userId); 
 }
 innerFunction.bind(this);
}
0 votes
Please login to submit your answer.