Why Does Intellisense Offer Json for a Constant?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?What does “use strict” do in JavaScript, and what is the reasoning behind it?What is JSONP, and why was it created?Why does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?Why does ++[[]][+[]]+[+[]] return the string “10”?

What's difference between "depends on" and "is blocked by" relations between issues in Jira next-gen board?

How to deal with a colleague who is being aggressive?

Gravitational effects of a single human body on the motion of planets

How to patch glass cuts in a bicycle tire?

Can I tell a prospective employee that everyone in the team is leaving?

Public transport tickets in UK for two weeks

Mercedes C180 (W204) dash symbol

What does kpsewhich stand for?

Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?

How to keep consistency across the application architecture as a team grows?

Why is unzipped directory exactly 4.0k (much smaller than zipped file)?

Dealing with spaghetti codebase, manager asks for things I can't deliver

Must a warlock replace spells with new spells of exactly their Pact Magic spell slot level?

Beginner looking to learn/master musical theory and instrumental ability. Where should I begin?

Python program to take in two strings and print the larger string

How did NASA Langley end up with the first 737?

Why do we need to chain the blocks (creating blockchain) in a permissioned blockchain?

Why did the person in charge of a principality not just declare themself king?

Manager questioning my time estimates for a project

Job Market: should one hide their (young) age?

Is it possible to prohibit all prohibitable schools of magic with a single character?

Need to read my home electrical Meter

Why A=2 and B=1 in the call signs for Spirit and Opportunity?

“For nothing” = “pour rien”?



Why Does Intellisense Offer Json for a Constant?


Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?What does “use strict” do in JavaScript, and what is the reasoning behind it?What is JSONP, and why was it created?Why does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?Why does ++[[]][+[]]+[+[]] return the string “10”?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I declared a constant, assigned to a fetch. Now, intellisense offers json for that constant.



Is it because vscode knows that fetch can return json?



import topHeadlinesURL from 'newsAPI.js';

// Delay execution until page loads
window.addEventListener('load', ()=>
kvetchNews();
);

async function kvetchNews()
const res = await fetch(topHeadlinesURL);
const json = await res.json();



enter image description here










share|improve this question



















  • 1





    This question doesn't really make sense. The ability to invoke .json on a variable isn't determined by how you declare that variable, var or let or const. It's determined by the value stored therein.

    – meagar
    Mar 24 at 0:55







  • 2





    The picture doesn't add any clarity. It's not clear why you think "constant" is relevant here; as already pointed out, fetch returns something that has a .json method on it, and VSCode knows this because fetch is a built-in standard function; it returns a promise, which you're awaiting, so the resolved value will be a Response object that has a .json method.

    – meagar
    Mar 24 at 0:59






  • 1





    Because there's no useful answer to give here. Intellisense offers .json because it knows .json is something you can invoke on the value stored in res, and its job is to suggest these things to save you time and keystrokes.

    – meagar
    Mar 24 at 1:05






  • 1





    Because fetch is a standard that is well defined.

    – meagar
    Mar 24 at 1:09







  • 1





    I guess one reason that this question is on hold is because the answer can be considered to not be useful. You believe it is, but sadly those who voted to put the question on hold did not.

    – evolutionxbox
    Mar 24 at 2:01

















-1















I declared a constant, assigned to a fetch. Now, intellisense offers json for that constant.



Is it because vscode knows that fetch can return json?



import topHeadlinesURL from 'newsAPI.js';

// Delay execution until page loads
window.addEventListener('load', ()=>
kvetchNews();
);

async function kvetchNews()
const res = await fetch(topHeadlinesURL);
const json = await res.json();



enter image description here










share|improve this question



















  • 1





    This question doesn't really make sense. The ability to invoke .json on a variable isn't determined by how you declare that variable, var or let or const. It's determined by the value stored therein.

    – meagar
    Mar 24 at 0:55







  • 2





    The picture doesn't add any clarity. It's not clear why you think "constant" is relevant here; as already pointed out, fetch returns something that has a .json method on it, and VSCode knows this because fetch is a built-in standard function; it returns a promise, which you're awaiting, so the resolved value will be a Response object that has a .json method.

    – meagar
    Mar 24 at 0:59






  • 1





    Because there's no useful answer to give here. Intellisense offers .json because it knows .json is something you can invoke on the value stored in res, and its job is to suggest these things to save you time and keystrokes.

    – meagar
    Mar 24 at 1:05






  • 1





    Because fetch is a standard that is well defined.

    – meagar
    Mar 24 at 1:09







  • 1





    I guess one reason that this question is on hold is because the answer can be considered to not be useful. You believe it is, but sadly those who voted to put the question on hold did not.

    – evolutionxbox
    Mar 24 at 2:01













-1












-1








-1








I declared a constant, assigned to a fetch. Now, intellisense offers json for that constant.



Is it because vscode knows that fetch can return json?



import topHeadlinesURL from 'newsAPI.js';

// Delay execution until page loads
window.addEventListener('load', ()=>
kvetchNews();
);

async function kvetchNews()
const res = await fetch(topHeadlinesURL);
const json = await res.json();



enter image description here










share|improve this question
















I declared a constant, assigned to a fetch. Now, intellisense offers json for that constant.



Is it because vscode knows that fetch can return json?



import topHeadlinesURL from 'newsAPI.js';

// Delay execution until page loads
window.addEventListener('load', ()=>
kvetchNews();
);

async function kvetchNews()
const res = await fetch(topHeadlinesURL);
const json = await res.json();



enter image description here







javascript json visual-studio-code






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 0:56







johny why

















asked Mar 24 at 0:51









johny whyjohny why

68811032




68811032







  • 1





    This question doesn't really make sense. The ability to invoke .json on a variable isn't determined by how you declare that variable, var or let or const. It's determined by the value stored therein.

    – meagar
    Mar 24 at 0:55







  • 2





    The picture doesn't add any clarity. It's not clear why you think "constant" is relevant here; as already pointed out, fetch returns something that has a .json method on it, and VSCode knows this because fetch is a built-in standard function; it returns a promise, which you're awaiting, so the resolved value will be a Response object that has a .json method.

    – meagar
    Mar 24 at 0:59






  • 1





    Because there's no useful answer to give here. Intellisense offers .json because it knows .json is something you can invoke on the value stored in res, and its job is to suggest these things to save you time and keystrokes.

    – meagar
    Mar 24 at 1:05






  • 1





    Because fetch is a standard that is well defined.

    – meagar
    Mar 24 at 1:09







  • 1





    I guess one reason that this question is on hold is because the answer can be considered to not be useful. You believe it is, but sadly those who voted to put the question on hold did not.

    – evolutionxbox
    Mar 24 at 2:01












  • 1





    This question doesn't really make sense. The ability to invoke .json on a variable isn't determined by how you declare that variable, var or let or const. It's determined by the value stored therein.

    – meagar
    Mar 24 at 0:55







  • 2





    The picture doesn't add any clarity. It's not clear why you think "constant" is relevant here; as already pointed out, fetch returns something that has a .json method on it, and VSCode knows this because fetch is a built-in standard function; it returns a promise, which you're awaiting, so the resolved value will be a Response object that has a .json method.

    – meagar
    Mar 24 at 0:59






  • 1





    Because there's no useful answer to give here. Intellisense offers .json because it knows .json is something you can invoke on the value stored in res, and its job is to suggest these things to save you time and keystrokes.

    – meagar
    Mar 24 at 1:05






  • 1





    Because fetch is a standard that is well defined.

    – meagar
    Mar 24 at 1:09







  • 1





    I guess one reason that this question is on hold is because the answer can be considered to not be useful. You believe it is, but sadly those who voted to put the question on hold did not.

    – evolutionxbox
    Mar 24 at 2:01







1




1





This question doesn't really make sense. The ability to invoke .json on a variable isn't determined by how you declare that variable, var or let or const. It's determined by the value stored therein.

– meagar
Mar 24 at 0:55






This question doesn't really make sense. The ability to invoke .json on a variable isn't determined by how you declare that variable, var or let or const. It's determined by the value stored therein.

– meagar
Mar 24 at 0:55





2




2





The picture doesn't add any clarity. It's not clear why you think "constant" is relevant here; as already pointed out, fetch returns something that has a .json method on it, and VSCode knows this because fetch is a built-in standard function; it returns a promise, which you're awaiting, so the resolved value will be a Response object that has a .json method.

– meagar
Mar 24 at 0:59





The picture doesn't add any clarity. It's not clear why you think "constant" is relevant here; as already pointed out, fetch returns something that has a .json method on it, and VSCode knows this because fetch is a built-in standard function; it returns a promise, which you're awaiting, so the resolved value will be a Response object that has a .json method.

– meagar
Mar 24 at 0:59




1




1





Because there's no useful answer to give here. Intellisense offers .json because it knows .json is something you can invoke on the value stored in res, and its job is to suggest these things to save you time and keystrokes.

– meagar
Mar 24 at 1:05





Because there's no useful answer to give here. Intellisense offers .json because it knows .json is something you can invoke on the value stored in res, and its job is to suggest these things to save you time and keystrokes.

– meagar
Mar 24 at 1:05




1




1





Because fetch is a standard that is well defined.

– meagar
Mar 24 at 1:09






Because fetch is a standard that is well defined.

– meagar
Mar 24 at 1:09





1




1





I guess one reason that this question is on hold is because the answer can be considered to not be useful. You believe it is, but sadly those who voted to put the question on hold did not.

– evolutionxbox
Mar 24 at 2:01





I guess one reason that this question is on hold is because the answer can be considered to not be useful. You believe it is, but sadly those who voted to put the question on hold did not.

– evolutionxbox
Mar 24 at 2:01












1 Answer
1






active

oldest

votes


















1














A few things; first:




Why Does Intellisense Offer Json for a Constant?




That the variable is a const isn't relevant to the methods the VSCode will suggest. The type of variable doesn't determine what methods can be invoked on it, the value of the variable does. Your variable could be declared var, let or const and it wouldn't change the suggestion of .json.



Second:




Is it because vscode knows that fetch can return json?




This demonstrates a misunderstanding of what VSCode is offering you. Whether or not a method returns JSON is irrelevant (fetch does not), VSCode is suggesting the method json because it knows that the object held by the variable has a json method.



In this case, fetch returns a promise, which resolves to a Response object that has implements the Body mixin, which provides a json method. You're awaiting that promise, so the value stored in the variable with be that response object, on which you can invoke json.



VSCode knows this, because fetch is part of a standard and well documented API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API



All VSCode is doing is offering you suggestions for which methods are available for you, saving you the effort of remembering the exact method names and typing them out. Not much of a savings for the four letter json method, but it can be useful for longer methods or for objects that have many methods.






share|improve this answer























  • Great and complete answer.

    – johny why
    Mar 26 at 1:17











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319774%2fwhy-does-intellisense-offer-json-for-a-constant%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














A few things; first:




Why Does Intellisense Offer Json for a Constant?




That the variable is a const isn't relevant to the methods the VSCode will suggest. The type of variable doesn't determine what methods can be invoked on it, the value of the variable does. Your variable could be declared var, let or const and it wouldn't change the suggestion of .json.



Second:




Is it because vscode knows that fetch can return json?




This demonstrates a misunderstanding of what VSCode is offering you. Whether or not a method returns JSON is irrelevant (fetch does not), VSCode is suggesting the method json because it knows that the object held by the variable has a json method.



In this case, fetch returns a promise, which resolves to a Response object that has implements the Body mixin, which provides a json method. You're awaiting that promise, so the value stored in the variable with be that response object, on which you can invoke json.



VSCode knows this, because fetch is part of a standard and well documented API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API



All VSCode is doing is offering you suggestions for which methods are available for you, saving you the effort of remembering the exact method names and typing them out. Not much of a savings for the four letter json method, but it can be useful for longer methods or for objects that have many methods.






share|improve this answer























  • Great and complete answer.

    – johny why
    Mar 26 at 1:17















1














A few things; first:




Why Does Intellisense Offer Json for a Constant?




That the variable is a const isn't relevant to the methods the VSCode will suggest. The type of variable doesn't determine what methods can be invoked on it, the value of the variable does. Your variable could be declared var, let or const and it wouldn't change the suggestion of .json.



Second:




Is it because vscode knows that fetch can return json?




This demonstrates a misunderstanding of what VSCode is offering you. Whether or not a method returns JSON is irrelevant (fetch does not), VSCode is suggesting the method json because it knows that the object held by the variable has a json method.



In this case, fetch returns a promise, which resolves to a Response object that has implements the Body mixin, which provides a json method. You're awaiting that promise, so the value stored in the variable with be that response object, on which you can invoke json.



VSCode knows this, because fetch is part of a standard and well documented API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API



All VSCode is doing is offering you suggestions for which methods are available for you, saving you the effort of remembering the exact method names and typing them out. Not much of a savings for the four letter json method, but it can be useful for longer methods or for objects that have many methods.






share|improve this answer























  • Great and complete answer.

    – johny why
    Mar 26 at 1:17













1












1








1







A few things; first:




Why Does Intellisense Offer Json for a Constant?




That the variable is a const isn't relevant to the methods the VSCode will suggest. The type of variable doesn't determine what methods can be invoked on it, the value of the variable does. Your variable could be declared var, let or const and it wouldn't change the suggestion of .json.



Second:




Is it because vscode knows that fetch can return json?




This demonstrates a misunderstanding of what VSCode is offering you. Whether or not a method returns JSON is irrelevant (fetch does not), VSCode is suggesting the method json because it knows that the object held by the variable has a json method.



In this case, fetch returns a promise, which resolves to a Response object that has implements the Body mixin, which provides a json method. You're awaiting that promise, so the value stored in the variable with be that response object, on which you can invoke json.



VSCode knows this, because fetch is part of a standard and well documented API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API



All VSCode is doing is offering you suggestions for which methods are available for you, saving you the effort of remembering the exact method names and typing them out. Not much of a savings for the four letter json method, but it can be useful for longer methods or for objects that have many methods.






share|improve this answer













A few things; first:




Why Does Intellisense Offer Json for a Constant?




That the variable is a const isn't relevant to the methods the VSCode will suggest. The type of variable doesn't determine what methods can be invoked on it, the value of the variable does. Your variable could be declared var, let or const and it wouldn't change the suggestion of .json.



Second:




Is it because vscode knows that fetch can return json?




This demonstrates a misunderstanding of what VSCode is offering you. Whether or not a method returns JSON is irrelevant (fetch does not), VSCode is suggesting the method json because it knows that the object held by the variable has a json method.



In this case, fetch returns a promise, which resolves to a Response object that has implements the Body mixin, which provides a json method. You're awaiting that promise, so the value stored in the variable with be that response object, on which you can invoke json.



VSCode knows this, because fetch is part of a standard and well documented API: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API



All VSCode is doing is offering you suggestions for which methods are available for you, saving you the effort of remembering the exact method names and typing them out. Not much of a savings for the four letter json method, but it can be useful for longer methods or for objects that have many methods.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 0:19









meagarmeagar

184k31278295




184k31278295












  • Great and complete answer.

    – johny why
    Mar 26 at 1:17

















  • Great and complete answer.

    – johny why
    Mar 26 at 1:17
















Great and complete answer.

– johny why
Mar 26 at 1:17





Great and complete answer.

– johny why
Mar 26 at 1:17



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319774%2fwhy-does-intellisense-offer-json-for-a-constant%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript