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;
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();
javascript json visual-studio-code
|
show 9 more comments
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();
javascript json visual-studio-code
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
orlet
orconst
. 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 becausefetch
is a built-in standard function; it returns a promise, which you'reawait
ing, so the resolved value will be aResponse
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 inres
, 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
|
show 9 more comments
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();
javascript json visual-studio-code
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();
javascript json visual-studio-code
javascript json visual-studio-code
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
orlet
orconst
. 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 becausefetch
is a built-in standard function; it returns a promise, which you'reawait
ing, so the resolved value will be aResponse
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 inres
, 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
|
show 9 more comments
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
orlet
orconst
. 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 becausefetch
is a built-in standard function; it returns a promise, which you'reawait
ing, so the resolved value will be aResponse
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 inres
, 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 await
ing, 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 await
ing, 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
|
show 9 more comments
1 Answer
1
active
oldest
votes
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 await
ing 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.
Great and complete answer.
– johny why
Mar 26 at 1:17
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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 await
ing 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.
Great and complete answer.
– johny why
Mar 26 at 1:17
add a comment |
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 await
ing 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.
Great and complete answer.
– johny why
Mar 26 at 1:17
add a comment |
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 await
ing 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.
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 await
ing 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.
answered Mar 25 at 0:19
meagar♦meagar
184k31278295
184k31278295
Great and complete answer.
– johny why
Mar 26 at 1:17
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
orlet
orconst
. 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 becausefetch
is a built-in standard function; it returns a promise, which you'reawait
ing, so the resolved value will be aResponse
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 inres
, 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