Javascript is a little bit different from java but the way how you used the programming language is just similar. For front end, what you need is an html, css and javascript. But since this is just a notes for javascript, you can just remove css. What you need now is just html where it will act as the main where the program starts. In html, this is what they call a boilerplate code. Meaning, you type in this a lot without any changes.
HTML
yourhtmlname.html
===================
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<meta>
<script src="yourjavascriptname.js" />
</head>
<body>
<script>document.write(displayHelloWorld())</script>
</body>
</html>
===================
JAVASCRIPT
yourjavascriptname.js
===================
function displayHelloWorld(){
return "Hello World of Javascript";
}
===================
Result:
Hello World of Javascript
Note:
1. Go to your yourhtmlname.html. Right click it and select open with browser. And the result will be displayed.
2. Html uses elements and this elements uses an opening tag and a closing tag like <html></html> respectively. Like in the title, the opening tag <title> and the closing tag </title>. And the words in between the title element is what you usually see in the very top of your browser above the domain name. So, going to the javascript, you can use the script element right away inside the body element of html but it would be better to make javascript external to the html. To make it external, use a script element in the head tag. You specify the following attributes in the opening script tag which is the type and the src. The and the src="yourjavascriptname.js". Take note that the src does change depending on the path on the file where you save it.
3. After you link your javascript to external, you can start programming right away. Starting with function. function is a keyword to indicate that this is a function and it is followed by the function name with a parenthesis. The keyword return is use when you want to return something like the literal "Hello World of Javascript".
4. Make sure that you always save it all before right clicking it to open with it in a browser or else the changes will not take effect.
YOU ARE READING
Javascript Programming
RandomI am just documenting things what i learned online in here. I do express things in my own words. And I create my own program samples which serves as my practice. I do this so that when someday I would need some notes to review, I can just visit in h...
