Why do some sections of code not autocomplete in the IDE

Tell us what’s happening:
Why doesn’t the IDE provide autocomplete for some items. For example during the typing of this line from the example hasOwnProperty doesn’t autopopulate. It does work when you run the code but the IDE makes it seem like hasOwnProperty isn’t valid.

This is the line I am talking about:
if(canary.hasOwnProperty(property)) {

Your code so far

function Bird(name) {
  this.name = name;
  this.numLegs = 2;

let canary = new Bird("Tweety");
let ownProps = [];
// Add your code below this line

for (let property in canary) {
  if(canary.hasOwnProperty(property)) {

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 12105.53.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.61 Safari/537.36.

Link to the challenge:

(AFAIK) almost everything is an object in JS, so methods on Object.prototype aren’t shown in the intellisense because they would appear everywhere (all JS data structures inherit from object). Having them autocomplete generally isn’t very useful, and for literal objects, what you normally want is the user-defined properties/methods (name/numlegs in this case). Naturally it’s a tradeoff, but whever team had say on this (at Microsoft I assume) decided this was best thing to do. If you hover over it once you’ve written it, you get the function signature, but you don’t get the intellisense before that.

There aren’t many methods to remember, thankfully – 7 non-deprectated methods, one of which is still classified as experimental. Whereas the properties name and numLegs will show as intellisense hints, as does push on
the array ownProps

1 Like

@DanCouper Thank you for taking the time to write such a great response. That makes a lot of sense.