DEVTOME.COM HOSTING COSTS HAVE BEGUN TO EXCEED 115$ MONTHLY. THE ADMINISTRATION IS NO LONGER ABLE TO HANDLE THE COST WITHOUT ASSISTANCE DUE TO THE RISING COST. THIS HAS BEEN OCCURRING FOR ALMOST A YEAR, BUT WE HAVE BEEN HANDLING IT FROM OUR OWN POCKETS. HOWEVER, WITH LITERALLY NO DONATIONS FOR THE PAST 2+ YEARS IT HAS DEPLETED THE BUDGET IN SHORT ORDER WITH THE INCREASE IN ACTIVITY ON THE SITE IN THE PAST 6 MONTHS. OUR CPU USAGE HAS BECOME TOO HIGH TO REMAIN ON A REASONABLE COSTING PLAN THAT WE COULD MAINTAIN. IF YOU WOULD LIKE TO SUPPORT THE DEVTOME PROJECT AND KEEP THE SITE UP/ALIVE PLEASE DONATE (EVEN IF ITS A SATOSHI) TO OUR DEVCOIN 1M4PCuMXvpWX6LHPkBEf3LJ2z1boZv4EQa OR OUR BTC WALLET 16eqEcqfw4zHUh2znvMcmRzGVwCn7CJLxR TO ALLOW US TO AFFORD THE HOSTING.

THE DEVCOIN AND DEVTOME PROJECTS ARE BOTH VERY IMPORTANT TO THE COMMUNITY. PLEASE CONTRIBUTE TO ITS FURTHER SUCCESS FOR ANOTHER 5 OR MORE YEARS!

JavaScript

JavaScript is a high-level programming language most commonly used for client-side scripting in the web browser. The language uses dynamic and weak typing, and provides support for several programming paradigms, including prototype-based object-oriented programming.

JavaScript engines are used to translate and execute code, traditionally using interpretation. Some more recent engines, such as Google Chrome's V8, instead compile the JavaScript to machine code before execution for significant performance gains.

Although they share a similar name, JavaScript actually has very little to do with the Java programming language. When named, JavaScript was intended to complement Java as a scripting language, but it has since become a distinct programming language of its own right. JavaScript is now a dialect of the EMCAScript scripting language standard, along with others such as JScript and ActionScript.

Features

Programming Paradigms

JavaScript uses a C-based syntax, allowing for imperative and structured programming styles. It also has several features that can be useful for functional programming, such as first-class functions and closures.

Whilst JavaScript does provide support for object-oriented programming, it uses a prototype-based style rather than the normal class-based style. An object will inherit methods and properties from its prototype, which is just another object. When a property is accessed, the initial object is first searched for the property. If it is not found, its prototype is then searched for the property, and then the prototype object's prototype, and so on. The prototype chain is traversed upwards until the property is found or 'Object' is reached. If the property is not found, it will evaluate to 'undefined' rather than causing an error.

Typing

JavaScript uses dynamic typing, meaning a variable can hold a value of any type regardless of what values and types it has previously held. It also uses weak typing, allowing implicit type conversions. For example, to evaluate operations between a string and a number, JavaScript will silently attempt to convert the string to a number or vice versa instead of throwing an error.

A demonstration of JavaScript's weak typing in Google Chrome's console:

> 5 * "3"
15
> "abc" + 1
"abc1"
> "abc" / 4
NaN
> 1 / 0
Infinity
> [1, 2, 3][17]
undefined

Use

JavaScript was designed to be a client-side scripting language in web browsers, providing a means for interaction with the user and the manipulation of the Document Object Model (DOM). This has always been JavaScript's most common application, but the language has recently seen a huge increase in use outside of the browser.

JavaScript is often used for desktop widgets and simple applications. HTML5 applications are becoming increasingly popular, largely due to their ability to run on most devices, including smartphones and tablets. Operating Systems are beginning to integrate these JavaScript based applications so that a web browser is not needed. This is the case with Windows 8 and, to an even further extent, Firefox OS.

JavaScript can also be used for server-side scripting through platforms like Node.js. Using the same language on both the client-side and server-side has many advantages.

Some applications, such as Unity and Adobe Photoshop, use JavaScript as a scripting language. Most modern browsers also allow additional functionality to be added through extensions in JavaScript.

Examples

Hello World

A simple "Hello world" program in JavaScript:

alert("Hello, world!");

Alternatively, the console can be used to display output:

console.log("Hello, world!");

Functions

Using an immediately-invoked function expression and closures to create a counter object:

var counter = (function() {
    var privateString = "Hi";
    var n = 0;
    return {
        increment: function() {
            n++;
        },
        output: function() {
            console.log(n);
        }
    };
}());
 
counter.increment();
counter.output();

DOM Manipulation

An example that changes the location of each link on the page:

var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
    links[i].href = "http://www.google.com";
}

Computing


QR Code
QR Code javascript (generated for current page)
 

Advertise with Anonymous Ads