Skip to content

Instantly share code, notes, and snippets.

@asifsaho
Created February 15, 2022 08:51
Show Gist options
  • Save asifsaho/5dfcbfebfc83eadc413869fd293159c4 to your computer and use it in GitHub Desktop.
Save asifsaho/5dfcbfebfc83eadc413869fd293159c4 to your computer and use it in GitHub Desktop.
JS interview question
console.log(add(5, 7)) // 12
console.log(add(5)(7)) // 12
console.log(add(3)(7)) // 10
function greet(greeting, punctuation) {
return greeting + ' ' + this.user + punctuation;
}
const freddy = { user: 'fred' };
console.log(greet.bind(freddy, 'hi')('!')); // 'hi fred!'
const asif= {
greet: function () {
function sayHi(this) {
console.log(`Hi ${this.name}`);
}
sayHi();
},
name: "Asif",
};
asif.greet()
const obj = {} console.log('obj' in obj); console.log('toString' in obj); console.log('toNumber' in obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment