Skip to content

Instantly share code, notes, and snippets.

@jonurry
Last active January 20, 2025 11:34
Show Gist options
  • Select an option

  • Save jonurry/6113de501d42ac397c6d49008ffb1844 to your computer and use it in GitHub Desktop.

Select an option

Save jonurry/6113de501d42ac397c6d49008ffb1844 to your computer and use it in GitHub Desktop.
6.4 Borrowing a Method (Eloquent JavaScript Solutions)
let map = {one: true, two: true, hasOwnProperty: true};
// Fix this call
//console.log(map.hasOwnProperty("one"));
console.log(hasOwnProperty.call(map, 'one'));
// → true
@jonurry
Copy link
Author

jonurry commented Feb 28, 2018

Hints

Remember that methods that exist on plain objects come from Object.prototype.

And that you can call a function with a specific this binding by using its call method.

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