background preloader

Javascript

Facebook Twitter

Edit this Fiddle. JavaScript Patterns. Improve your jQuery - 25 excellent tips. Official jQuery Blog - powered by FeedBurner. Things you may not know about jQuery. I was going to do a bit of a series, releasing a jQuery tip every day or week or something, but I think I’m a little too lazy to commit to something like that. So I’ve compiled them all into one post! I’ll probably add to the list at later dates so make sure to bookmark it! Do you have a tip nobody knows about? – Add it in the comments… JavaScript Garden. Function Declarations and Expressions Functions in JavaScript are first class objects. That means they can be passed around like any other value. One common use of this feature is to pass an as a callback to another, possibly asynchronous function.

The function Declaration function foo () {} The above function gets hoisted before the execution of the program starts; thus, it is available in the scope it was in, even if called before the actual definition in the source. foo (); // Works because foo was created before this code runs The function Expression var foo = function () {}; This example assigns the unnamed and function to the variable foo . foo ; // 'undefined' foo (); // this raises a TypeError Due to the fact that var is a declaration that hoists the variable name foo before the actual execution of the code starts, foo is already defined when the script gets executed.

Named Function Expression Another special case is the assignment of named functions. var foo = function bar () { this ; b ! JavaScript. JavaScript (JS) is a lightweight interpreted (or just-in-time compiled) programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat.

JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. JavaScript's dynamic capabilities include runtime object construction, variable parameter lists, function variables, dynamic script creation (via eval), object introspection (via for...in and Object utilities), and source-code recovery (JavaScript functions store their source text and can be retrieved through toString()). This section is dedicated to the JavaScript language itself, and not the parts that are specific to Web pages or other host environments. Looking to become a front-end web developer? Get started.