2

I just ran into some strange behavior using VSCode writing a JS file.

See that I'm trying to access the hasOwnProperty() method on the fluffy object. And VSCode didn't autocomplete or suggest anything on my line of code.

At this point I'm already thinking that I'm doing something wrong and that I'm probably not able to access this method through my object.

But the interesting thing is:

enter image description here

QUESTION:

As soon as a finish typing hasOwnProperty and I open the parenthesis, VSCode triggers the IntelliSense and recognizes the method. Is it normal? How come VSCode doesn't show me all the properties and methods available to my object since the first letter that I've typed?

Thanks in advance for your help.

VSCode About: Version: 1.25.1 Date: 2018-07-11T15:43:53.668Z Electron: 1.7.12 Chrome: 58.0.3029.110 Node.js: 7.9.0 V8: 5.8.283.38 Architecture: x64

1 Answer 1

1

Yes this is expected. We don't show intellisense suggestions for Object.prototype properties because they would show up on pretty much every object and are therefore not very useful. However the language smarts do know that hasOwnProperty exists, which is why you get signature help for it

Sign up to request clarification or add additional context in comments.

2 Comments

The same reason for 'array.length'? But WebStorm will autocomplete this, why?
No, .length is suggested on arrays

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.