Hello Hello Hello

Only available on StudyMode
  • Topic: JavaScript, HTML, ECMAScript
  • Pages : 17 (2848 words )
  • Download(s) : 45
  • Published : February 22, 2013
Open Document
Text Preview
JavaScript
* is an open source client-side scripting language commonly implemented as part of a web browser in order to create enhanced user interfaces and dynamic websites.

* JavaScript is prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It uses syntax influenced by the language C. JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics. The key design principles within JavaScript are taken from the Self and Scheme programming languages.

* <syntaxhighlight lang="html4strict">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN
<"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>simple page</title></head> <body>
<h1 id="header">This is JavaScript</h1>
<script type="application/javascript">
document.body.appendChild(document.createTextNode('Hello World!')); var h1 = document.getElementById("header"); // holds a reference to the <h1> tag h1 = document.getElementsByTagName("h1")[0]; // accessing the same <h1> element </script>

<noscript>Your browser either does not support JavaScript, or has JavaScript turned off.</noscript> </body>
</html>
</syntaxhighlight>
<syntaxhighlight lang="html4strict">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN
<"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>simple page</title></head> <body>
<h1 id="header">This is JavaScript</h1>
<script type="application/javascript">
document.body.appendChild(document.createTextNode('Hello World!')); var h1 = document.getElementById("header"); // holds a reference to the <h1> tag h1 = document.getElementsByTagName("h1")[0]; // accessing the same <h1> element </script>

<noscript>Your browser either does not support JavaScript, or has JavaScript turned off.</noscript> </body>
</html>
</syntaxhighlight>
JavaScript's use in applications outside web pages — for example in PDF documents, site-specific browsers, and desktop widgets—is also significant. Newer and faster JavaScript VMs and frameworks built upon them (notably Node.js) have also increased the popularity of JavaScript for server-side web applications. JavaScript was formalized in the ECMA Script language standard and is primarily used in the form of client-side JavaScript (as part of a web browser). This enables programmatic access to computational objects within a host environment.

Above is a minimal example of a standards-conforming web page containing JavaScript (using [[HTML|HTML 4.01]] syntax) and the [[Document object model |DOM]]
Extract/Source: www.wikipedia.org 01-20-13
JavaScript Codes

Append an array to another array : Milliseconds since epoch: var a = [4,5,6];
var b = [7,8,9];
Array.prototype.push.apply(a, b);

uneval(a); // is: [4, 5, 6, 7, 8, 9]
var a = [4,5,6];
var b = [7,8,9];
Array.prototype.push.apply(a, b);

uneval(a); // is: [4, 5, 6, 7, 8, 9]

+new Date() // 1259359833574
+new Date() // 1259359833574

foo: 0
bar: 0
foo: 1
bar: 1
foo: 2
bar: 2
foo: 3
bar: 3
foo: 4
bar: 4
foo: 0
bar: 0
foo: 1
bar: 1
foo: 2
bar: 2
foo: 3
bar: 3
foo: 4
bar: 4
//// thread definition
function Thread( name ) {

for ( var i = 0; i < 5; i++ ) {

Print(name+': '+i);
yield;
}
}
//// thread management
var threads = [];

// thread creation
threads.push( new Thread('foo') );
threads.push( new Thread('bar') );

// scheduler
while (threads.length) {

var thread = threads.shift();
try {
thread.next();
threads.push(thread);
} catch(ex if ex...
tracking img