{"id":932,"date":"2014-10-05T04:02:48","date_gmt":"2014-10-05T04:02:48","guid":{"rendered":"http:\/\/javascript-tutor.net\/?p=932"},"modified":"2016-07-25T03:03:00","modified_gmt":"2016-07-25T03:03:00","slug":"writing-a-javascript","status":"publish","type":"post","link":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/","title":{"rendered":"Writing a JavaScript"},"content":{"rendered":"<p>Writing a JavaScript is very simple, you do not need a special program to create a JavaScript, what you need is a simple text editor like Notepad. However, a better editor is Notepad++, which is available online for free. Click to download <a href=\"https:\/\/notepad-plus-plus.org\/download\/v6.9.html\">\u00a0https:\/\/notepad-plus-plus.org\/download\/v6.9.html<\/a>.<\/p>\n<p>You can either embed a JavaScript in a HTML document or you can create a JavaScript file and then reference it in a HTML document using the keyword SRC.<\/p>\n<p>For example, you can embed the text &#8220;Welcome to my tutorial&#8221; in the following HTML document<\/p>\n<p>&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;JavaScript Demo 1&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;h1&gt;JavaScript Demo 1&lt;\/h1&gt;<br \/>\n&lt;Script type=&#8221;text\/javascript&#8221;&gt;<br \/>\ndocument.write(&#8216;&lt;h2&gt;Welcome to my\u00a0tutorial&gt;&lt;\/h2&gt;&#8217;);<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>Alternatively you can create a JavaScript file and referencing it from a HTML document, as follows:<\/p>\n<p>Open notepad and enter the following line<\/p>\n<p>document.write(&#8216;&lt;h1&gt;Welcome to my\u00a0tutorial&lt;\/h1&gt;&#8217;)<\/p>\n<p>save the file as j01.js and save it in the folder jscript<\/p>\n<p>Now use notepad to create the following HTML file<\/p>\n<p>&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;Javascript Demo 1&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;h1&gt;JavaScript Demo 1&lt;\/h1&gt;<br \/>\n&lt;script src=&#8221;jscript\/j01.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>The &lt;script&gt; element is used to load the JavaScript file into the page using the attribute src, which link to the path of the script that we have created.<\/p>\n<p>Comparing the two methods, it is always better to create the JavaScript file than embedding\u00a0it into the HTML document as it made debugging simpler. If errors occur you just need to edit the JavaScript file. Further, you can reuse the script in another part of the document or other HTML documents.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Writing a JavaScript is very simple, you do not need a special program to create a JavaScript, what you need is a simple text editor like Notepad. However, a better editor is Notepad++, which is available online for free. Click to download \u00a0https:\/\/notepad-plus-plus.org\/download\/v6.9.html. You can either embed a JavaScript in a HTML document or you &hellip; <a href=\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Writing a JavaScript&#8221;<\/span><\/a><\/p>\n","protected":false},"author":35895,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-932","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Writing a JavaScript - javascript tutorial<\/title>\n<meta name=\"description\" content=\"This article discusses ways in creating javascript\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Writing a JavaScript - javascript tutorial\" \/>\n<meta property=\"og:description\" content=\"This article discusses ways in creating javascript\" \/>\n<meta property=\"og:url\" content=\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn JavaScript Online | Free Interactive JavaScript Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-05T04:02:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-07-25T03:03:00+00:00\" \/>\n<meta name=\"author\" content=\"Liew Voon Kiong\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Liew Voon Kiong\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/\",\"url\":\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/\",\"name\":\"Writing a JavaScript - javascript tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/javascript-tutor.net\/#website\"},\"datePublished\":\"2014-10-05T04:02:48+00:00\",\"dateModified\":\"2016-07-25T03:03:00+00:00\",\"author\":{\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8\"},\"description\":\"This article discusses ways in creating javascript\",\"breadcrumb\":{\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/javascript-tutor.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Writing a JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/javascript-tutor.net\/#website\",\"url\":\"https:\/\/javascript-tutor.net\/\",\"name\":\"Learn JavaScript Online | Free Interactive JavaScript Tutorials\",\"description\":\"Master JavaScript with free, interactive tutorials for beginners and experienced coders. Practice live coding and visualize how JavaScript works step by step.\",\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8\",\"name\":\"Liew Voon Kiong\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/javascript-tutor.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g\",\"caption\":\"Liew Voon Kiong\"},\"url\":\"https:\/\/javascript-tutor.net\/index.php\/author\/ajt7051jct\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Writing a JavaScript - javascript tutorial","description":"This article discusses ways in creating javascript","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Writing a JavaScript - javascript tutorial","og_description":"This article discusses ways in creating javascript","og_url":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/","og_site_name":"Learn JavaScript Online | Free Interactive JavaScript Tutorials","article_published_time":"2014-10-05T04:02:48+00:00","article_modified_time":"2016-07-25T03:03:00+00:00","author":"Liew Voon Kiong","twitter_misc":{"Written by":"Liew Voon Kiong","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/","url":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/","name":"Writing a JavaScript - javascript tutorial","isPartOf":{"@id":"https:\/\/javascript-tutor.net\/#website"},"datePublished":"2014-10-05T04:02:48+00:00","dateModified":"2016-07-25T03:03:00+00:00","author":{"@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8"},"description":"This article discusses ways in creating javascript","breadcrumb":{"@id":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/javascript-tutor.net\/index.php\/2014\/10\/05\/writing-a-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/javascript-tutor.net\/"},{"@type":"ListItem","position":2,"name":"Writing a JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/javascript-tutor.net\/#website","url":"https:\/\/javascript-tutor.net\/","name":"Learn JavaScript Online | Free Interactive JavaScript Tutorials","description":"Master JavaScript with free, interactive tutorials for beginners and experienced coders. Practice live coding and visualize how JavaScript works step by step.","inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/63d832c3efdf443517b5f5bfd1b93df8","name":"Liew Voon Kiong","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/javascript-tutor.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/413ad70576fa5f43c1d3ae3429c92579c21f536c350e6470302fa25ddd9b6a13?s=96&d=mm&r=g","caption":"Liew Voon Kiong"},"url":"https:\/\/javascript-tutor.net\/index.php\/author\/ajt7051jct\/"}]}},"_links":{"self":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/users\/35895"}],"replies":[{"embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/comments?post=932"}],"version-history":[{"count":5,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/932\/revisions"}],"predecessor-version":[{"id":1508,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/posts\/932\/revisions\/1508"}],"wp:attachment":[{"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/media?parent=932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/categories?post=932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javascript-tutor.net\/index.php\/wp-json\/wp\/v2\/tags?post=932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}