Skip to content

Instantly share code, notes, and snippets.

@prmishra
Last active May 26, 2019 14:38
Show Gist options
  • Save prmishra/48a1333f5161f97d97ab4df23e9af106 to your computer and use it in GitHub Desktop.
Save prmishra/48a1333f5161f97d97ab4df23e9af106 to your computer and use it in GitHub Desktop.
var args = process.argv.slice(2);
var hero = {
name: args[0],
getSecretIdentity: function (){
return this.name;
}
};
var stoleSecretIdentity = hero.getSecretIdentity;
console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());
// node script.js bruce-wayne
@sagar-more
Copy link

sagar-more commented Apr 15, 2019

var args = process.argv.slice(2);

var hero = {
    name: args[0],
    getSecretIdentity: function (){
        return this.name;
    }
};

var stoleSecretIdentity = hero.getSecretIdentity.bind(hero);

console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

// node script.js bruce-wayne

@vaidyaprasanna
Copy link

var args = process.argv.slice(2);

var hero = {
name: args[0],
getSecretIdentity: function (){
return this.name;
}
};

var stoleSecretIdentity = hero.getSecretIdentity,bind(hero);

console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

@muhammad-amin-8102
Copy link

var args = process.argv.slice(2);

var hero = {
name: args[0],
getSecretIdentity: function (){
return this.name;
}
};

var stoleSecretIdentity = hero.getSecretIdentity.bind(hero);

console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

// node script.js bruce-wayne

@shreyag020
Copy link

var args = process.argv.slice(2);

var hero = {
name: args[0],
getSecretIdentity: function (){
return this.name;
}
};

var stoleSecretIdentity = hero.getSecretIdentity.bind(hero);

console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

// node script.js bruce-wayne

@ashvini-maurya
Copy link

var args = process.argv.slice(2);

var hero = {
  name: args[0],
  getSecretIdentity: function() {
    return this.name;
  }
};

var stoleSecretIdentity = hero.getSecretIdentity.bind(hero);

console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

@Piyush-85
Copy link

Piyush-85 commented May 26, 2019

var args = process.argv.slice(2);

var hero = {
name: args[0],
getSecretIdentity: function (){
return this.name;
}
};

var stoleSecretIdentity = hero.getSecretIdentity.bind(hero);

console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment