JavaScript Technology

Introduction to JavaScript

Internet
The Internet is the global system of interconnected computer networks that use the Internet protocol suite (TCP/IP) to link devices worldwide. It is a network of networks that consists of private, public, academic, business, and government networks of local to global scope, linked by a broad array of electronic, wireless, and optical networking technologies. The Internet carries a vast range of information resources and services, such as the inter-linked hypertext documents and applications of the World Wide Web (WWW), electronic mail, telephony, and file sharing.

World Wide Web(WWW)
The World Wide Web (abbreviated WWW or the Web) is an information space where documents and other web resources are identified by Uniform Resource Locators (URLs), interlinked by hypertext links, and can be accessed via the Internet.
English scientist Tim Berners-Lee invented the World Wide Web in 1989. He wrote the first web browser computer program in 1990 while employed at CERN in Switzerland.

Explanation
We store information in computer. Computers are interconnected through Internet to access information.
We generally need a browser like Internet Explorer, Mozila firefox or Google Chrome to access Internet.
Then when we open the browser we type an url like www.google.com. Here we are actually calling a computer which has certain information stored in it.

Web pages are primarily text documents formatted and annotated with Hypertext Markup Language (HTML).
In addition to formatted text, web pages may contain images, video, audio, and software components that are rendered in the user’s web browser as coherent pages of multimedia content.

Embedded hyperlinks permit users to navigate between web pages. Multiple web pages with a common theme, a common domain name, or both, make up a website.

Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications. It works with Cascading Style Sheets (CSS) and JavaScript.

Cascading Style Sheets (CSS) is a style sheet language which is used to make a web page beautiful.

JavaScript(JS)
JavaScript is the programming language of HTML and the Web.
Alongside HTML and CSS, JavaScript is one of the three core technologies of World Wide Web content production
It is used to make a website interactive.

Ex: Suppose you are doing Facebook. You tried to post something but without writing anything in the comment box you tried to hit the “POST” button.
It will throw an error. This is done with JavaScript.

Computer Languages
*Programming Languages example- Java, PHP, JavaScript. A Programing Language is a set of instruction for computer to perform specific tasks.
*Markup Languages examples HTML is used to present a document or represent a structured data.
When we open a website we see the texts are aligned in a manner. Some words are highlighted. The pages are formated. This is done through Markup Languages.

Programing Languages.
Scripting Languages – Languages which are interpreted by the processor. And it requires a separate application like web browsers(chrome, firefox) to run.
Compiled Languages – Languages are compiled by processor. Have their own application to run. Like installed games in PC.

We generally write a computer program using a high-level language. A high-level language is one which is understandable by us humans. It contains words and phrases from the English (or other) language. But a computer does not understand high-level language. It only understands program written in 0’s and 1’s in binary, called the machine code. A program written in high-level language is called a source code. We need to convert the source code into machine code and this is accomplished by compilers and interpreters. Hence, a compiler or an interpreter is a program that converts program written in high-level language into machine code understood by the computer.

Interpreter
Translates program one statement at a time.
It takes less amount of time to analyze the source code but the overall execution time is slower.
Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy.
Are Memory efficient.
Programming language JavaScript, PHP

Compiler
Scans the entire program and translates it as a whole into machine code.
It takes large amount of time to analyze the source code but the overall execution time is comparatively faster.
Requires more memory
It generates the error message only after scanning the whole program. Hence debugging is comparatively hard.
Programming language – C, C++

JAVASCRIPT Beginning
JavaScript operates with HTML.
JavaScript can change HTML, contents, elements and style.
Can Show/hide HTML elements.

Task Copy the following code below remove * and save it in a file
myFirstHtml.html and open the file with a browser.
************************************

<*!DOCTYPE html>
<*html>
<*body>

<*h2>My First JavaScript

<*button type="button" onclick="document.getElementById('demo').innerHTML = Date()">
Click me to display Date and Time.

<*p id="demo">

<*/body>
<*/html>

****************************************

JavaScript can be internal or external.
Internal are those in which the javascript code is written in html page itself within tags.
example-

<*!DOCTYPE html>
<*html>
<*head>
<*script>
function myFunction() {
document.getElementById(“demo”).innerHTML = “Paragraph changed.”;
}
<*/script>
<*/head>

<*body>

<*h2>JavaScript in Head

<*p id="demo">A Paragraph.

<*button type="button" onclick="myFunction()">Try it

<*/body>
<*/html>

or JavaScipt can be external. Where Javascript code is written in a seperate javascript file and is included in the html page.
example-
save the following code is file try.html
<*!DOCTYPE html>
<*html>
<*body>

<*h2>External JavaScript

<*p id="demo">A Paragraph.

<*button type="button" onclick="myFunction()">Try it

<*p>(myFunction is stored in an external file called “”)

<*script src="">

<*/body>
<*/html>

and save the following code in the same directory as

function myFunction() {
document.getElementById(“demo”).innerHTML=”Paragraph changed.”;
}