background preloader

Google JavaScript Style Guide

Google JavaScript Style Guide
We follow the C++ formatting rules in spirit, with the following additional clarifications. Curly Braces Because of implicit semicolon insertion, always start your curly braces on the same line as whatever they're opening. For example: if (something) { // ... } else { // ... } Array and Object Initializers Single-line array and object initializers are allowed when they fit on a line: Multiline array initializers and object initializers are indented 2 spaces, with the braces on their own line, just like blocks. Long identifiers or values present problems for aligned initialization lists, so always prefer non-aligned initialization. Not like this: Function Arguments When possible, all function arguments should be listed on the same line. // Four-space, wrap at 80. When the function call is itself indented, you're free to start the 4-space indent relative to the beginning of the original statement or relative to the beginning of the current function call. Passing Anonymous Functions Blank lines

http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml

Related:  javascript

JavaScript JavaScript (JS) is a lightweight, interpreted, 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 and Apache CouchDB. JS is a prototype-based, multi-paradigm, dynamic scripting language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. Read more about JavaScript. This section of the site is dedicated to the JavaScript language itself, and not the parts that are specific to Web pages or other host environments.

Insider Tips for Using Apps Script and Spreadsheets My role in Google Docs is to help manage many projects across Google Docs/Drive. As a part of my job, I ask for a fair amount of data from all of those teams and generate reports on project/feature status. To make this much simpler for everyone involved, I have created a lot of simple tools using Google Spreadsheets and Apps Script (as well as a lot of complex tools) that make it easier for collaborators to enter data and for me to collect that data and create reports. Below is a pair of foundational techniques that I include in nearly every Spreadsheet/Apps Script tool I build. Load Settings From a Configuration Sheet I have a dozens of scripts generating reports.

Introduction to RequireJS In this tutorial we are going to take a look at RequireJS, an AMD compatible asynchronous script loader that is incredibly powerful. In my experiments with RequireJS I've hugely enjoyed working with it and will be using it heavily in my future development. This is a fairly heavy post as far as complexity goes, but please do stick with it. I struggled to get my head around RequireJS and AMD for a long time but once it "clicks" it is really awesome. The basic use case for RequireJS is as a basic script loader, but in this tutorial I wont concentrate on that, but on its uses for modular development. SimpleYUI is a new way of loading and instantiating YUI. The SimpleYUI file contains a rollup of basic Ajax library functionality: DOM tasks, event abstraction, transitions, and Ajax. Unlike other ways of loading YUI, SimpleYUI creates a YUI instance immediately upon loading, binding all included components to a global Y . Using SimpleYUI is easy:

Mapbox: the jQuery Map Most Recent Blog Post:jQuery Mapbox Updated Click to toggle dark text on white Home » Plugins » Mapbox Get latest code here. Or get the outdated (but still working) version:[ Click here for the mapbox.min.js code - Click here for the uncompressed code ] $().mapbox(). Human JavaScript Code is as much about people as it is about computers. Sure, it's run by computers, but it's written by, maintained by, and ultimately created for people. People are not computers. We are not robots. 11 Multi-touch and Touch events Javascript libraries Touch screen devices are ruling the mobile platform nowadays. Most of the smart phones have it, tablet and based on the trend, it's slowly come to our desktop as well. To develop a touch screen compatible web applications or website, you can use the existing touch events of the browsers or the platforms.

Understanding JavaScript’s this keyword (In Portugese) The JavaScript this keyword is ubiquitous yet misconceptions abound. What you need to know Every execution context has an associated ThisBinding whose lifespan is equal to that of the execution context and whose value is constant. Extensive Collection Of jQuery Drag And Drop Plugins Don't Forget to participate in a contest where you can win an amazing e-Commerce template from TemplateMonster. jQuery allows you to create stylish yet user friendly websites that are not only pleasing to the eye but also are very lightweight and load quite quickly. This is the reason why jQuery has a special place in the field of web development. jQuery is getting better day by day thanks to the jQuery community that continuously share awesome plugins. At the moment, we are sharing with your some extraordinarily amazing jQuery plugins for drag and drop feature. With these plugins, you will allow your visitors to personalize the website and its tools according to their needs; and in this way you provide them with loads of customization option that every user simply love! We hope that you will like this collection and find these plugins helpful for you.

Mastering The Developer Tools Console The developer tools console is one of the most powerful tools available to you when it comes to debugging your front-end web applications. The console has an API that provides a number of methods that make debugging easier. It’s not uncommon to see developers using console.log() or console.dir() to investigate problems; but the developer tools console has a lot more to offer. In this blog post you’re going to learn how to debug your web applications using the methods provided by the console API. Some browsers support more functionality than others so I’ll be pointing out any compatibility issues as we go. Introducing the Script Service Triggers in Apps Script allow you to schedule your script’s execution in response to an event, at a specific time and date, or at given time intervals. Publishing scripts as services allows you to deploy your web apps with a click of a button. The new Script service lets you perform both of these tasks programmatically. With the Script service at your disposal, you can create smooth install flows, chain your scripts’ executions, generate summaries of current triggers, and even programmatically publish the scripts as services.

The Top 10 Javascript MVC Frameworks Reviewed - CodeBrief UPDATE 1/14/2012: Added Batman.js and Angular.js due to popular demand and because they looked impressive. Over the last several months I have been in a constant search for the perfect javascript MVC framework. Driven by a dire need for the right level of abstraction and features, I have tried out - some more cursorily than others - every framework I could get my hands on. Here lies a brief synopsis of each framework. Lastly, I share the framework which I ultimately decided on.

Google Closure: How not to write JavaScript At the Edge of the Web conference in Perth last week I got to catch up with Dmitry Baranovskiy, the creator of the Raphaël and gRaphaël JavaScript libraries. Perhaps the most important thing these libraries do is make sophisticated vector graphics possible in Internet Explorer, where JavaScript performance is relatively poor. Dmitry, therefore, has little patience for poorly-written JavaScript like the code he found in Google’s just-released Closure Library. Having delivered a talk on how to write your own JavaScript library (detailed notes) at the conference, Dmitry shared his thoughts on the new library over breakfast the next morning. “Just what the world needs—another sucky JavaScript library,” he said. When I asked him what made it ‘sucky’, he elaborated.

JS Objects: De"construct"ion JS Objects: TL;DR JavaScript has been plagued since the beginning with misunderstanding and awkwardness around its "prototypal inheritance" system, mostly due to the fact that "inheritance" isn't how JS works at all, and trying to do that only leads to gotchas and confusions that we have to pave over with user-land helper libs. Instead, embracing that JS has "behavior delegation" (merely delegation links between objects) fits naturally with how JS syntax works, which creates more sensible code without the need of helpers. When you set aside distractions like mixins, polymorphism, composition, classes, constructors, and instances, and only focus on the objects that link to each other, you gain a powerful tool in behavior delegation that is easier to write, reason about, explain, and code-maintain. Simpler is better.

Related:  JavaScript1. JavaScript Basics