How to run JavaScript?
In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed
<script type="text/javascript">
and hit enter, but I got error message
Uncaught Syntax error: Unexpected Token<
Why?
javascript google-chrome-devtools
add a comment |
In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed
<script type="text/javascript">
and hit enter, but I got error message
Uncaught Syntax error: Unexpected Token<
Why?
javascript google-chrome-devtools
What are you trying to practice? We can run JavaScript code easy in console
– Pramod Kharade
Nov 21 '18 at 4:31
1
That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag</script>
.
– Amy
Nov 21 '18 at 4:32
add a comment |
In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed
<script type="text/javascript">
and hit enter, but I got error message
Uncaught Syntax error: Unexpected Token<
Why?
javascript google-chrome-devtools
In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed
<script type="text/javascript">
and hit enter, but I got error message
Uncaught Syntax error: Unexpected Token<
Why?
javascript google-chrome-devtools
javascript google-chrome-devtools
edited Nov 21 '18 at 5:26
Harsh Patel
1,67811229
1,67811229
asked Nov 21 '18 at 4:29
CathyCathy
124
124
What are you trying to practice? We can run JavaScript code easy in console
– Pramod Kharade
Nov 21 '18 at 4:31
1
That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag</script>
.
– Amy
Nov 21 '18 at 4:32
add a comment |
What are you trying to practice? We can run JavaScript code easy in console
– Pramod Kharade
Nov 21 '18 at 4:31
1
That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag</script>
.
– Amy
Nov 21 '18 at 4:32
What are you trying to practice? We can run JavaScript code easy in console
– Pramod Kharade
Nov 21 '18 at 4:31
What are you trying to practice? We can run JavaScript code easy in console
– Pramod Kharade
Nov 21 '18 at 4:31
1
1
That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag
</script>
.– Amy
Nov 21 '18 at 4:32
That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag
</script>
.– Amy
Nov 21 '18 at 4:32
add a comment |
2 Answers
2
active
oldest
votes
The console defaults to run javascript so you need not specify
<script type="text/javascript">
this explicitly it understands so just try to run the javascript as it is and it should be working fine.
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
add a comment |
Please use the following website for JS practice
https://jsfiddle.net
Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.
And <script>
is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.
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%2f53405271%2fhow-to-run-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The console defaults to run javascript so you need not specify
<script type="text/javascript">
this explicitly it understands so just try to run the javascript as it is and it should be working fine.
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
add a comment |
The console defaults to run javascript so you need not specify
<script type="text/javascript">
this explicitly it understands so just try to run the javascript as it is and it should be working fine.
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
add a comment |
The console defaults to run javascript so you need not specify
<script type="text/javascript">
this explicitly it understands so just try to run the javascript as it is and it should be working fine.
The console defaults to run javascript so you need not specify
<script type="text/javascript">
this explicitly it understands so just try to run the javascript as it is and it should be working fine.
answered Nov 21 '18 at 6:16
Sundeep PiduguSundeep Pidugu
39912
39912
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
add a comment |
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?
– Cathy
Nov 23 '18 at 0:30
add a comment |
Please use the following website for JS practice
https://jsfiddle.net
Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.
And <script>
is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.
add a comment |
Please use the following website for JS practice
https://jsfiddle.net
Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.
And <script>
is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.
add a comment |
Please use the following website for JS practice
https://jsfiddle.net
Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.
And <script>
is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.
Please use the following website for JS practice
https://jsfiddle.net
Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.
And <script>
is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.
answered Nov 21 '18 at 4:35
GoldyGoldy
348314
348314
add a comment |
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%2f53405271%2fhow-to-run-javascript%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
What are you trying to practice? We can run JavaScript code easy in console
– Pramod Kharade
Nov 21 '18 at 4:31
1
That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag
</script>
.– Amy
Nov 21 '18 at 4:32