Let talk a bit about it evolution, Its first specifiction was written in 1997 then after 02 years they added many features such as the try/catch exception handling, regular expression and other new control statements, 10 years later in 2009 many features were added such as library sorpot for JSON the "strit mode" for more error filtering, setters, getters ..., and the major version(ES6) was published in 2015 with many paradim to mimic the Object Oriented Languages.
Add new HTML to the page, change the existing content, modify styles.
React to user actions, run on mouse clicks, pointer movements, key presses.
Get and set cookies, ask questions to the visitor, show messages.
Remember the data on the client-side (“local storage”).
This project has dramastically change the way modern application are build today as you can see on the picture bellow the list of some biggest tech company which are using it.
Modern tools make the transpilation very fast and transparent, actually allowing developers to code in another language and auto-converting it “under the hood”.
Amont those languages with can have:
TypeScript is concentrated on adding “strict data typing” to simplify the development and support of complex systems. It is developed by Microsoft.
(ES6) EmacScript-6 Syntax
Let asume that you have the above mentioned tools up and running. Open your text-editor and type the following code snippet and seved as
<!--your html code here -->
alert( 'Hello, world!' );
<!-- your code -->
let explain how this code is working. The interpreter scan the code till it reach the first script tag, it start by the first line within the tag and execute line after line. So, for our case here it found only one line
Save the file and open it with your browser,
As you may guest we have the
alert() keyword that has as function to display what was passed in it's parentases in our case
'Hello, World!' please go further and play with it by changing the value to what ever you want.
// Add your code here
alert( 'Hello, world!' );
Once we done, we simply include the file into our html like the following line of code
/path/to/script.js is an absolute path to the file with the script (from the site root). It is also possible to provide a path relative to the current page.
src="script.js" would mean a file
"script.js" in the current folder.
We can give a full URL as well. For instance:
We can even attached several script, with multiple tags as follow:
srcis set, the script content is ignored. A single
<script>tag can’t have both the
srcattribute and the code inside. This won’t work:
alert(15); // the content is ignored, because src is set
We must choose: either it’s an external
<script src="…"> or a regular
<script> with code. The example above can be split into two scripts to work:
Let end here and you should keep in your mind that the best way to learn programming is to by written code. So, use what you have learn today to display what ever text you can think :) and jumb to the next article when ready.
By receiving free stock articles and smart tutorials to advance your career...