background preloader

JavaScript

Facebook Twitter

JSLint Error Explanations - Making Your Feelings Better. OOP In JavaScript: What You NEED to Know. (Object Oriented JavaScript: Only Two Techniques Matter) Prerequisite:JavaScript Objects in DetailJavaScript Prototype Object Oriented Programming (OOP) refers to using self-contained pieces of code to develop applications. We call these self-contained pieces of code objects, better known as Classes in most OOP programming languages and Functions in JavaScript.

We use objects as building blocks for our applications. Our Career Paths and Courses Website Is Now Live New UPDATE: June 8, 2015 Enrollment for our Career Paths is well underway. The second cohort for Career Path 5: Modern Fullstack Developer is also full. In this article, we are concerned with only Inheritance and Encapsulation since only these two concepts apply to OOP in JavaScript, particularly because, in JavaScript, objects can encapsulate functionalities and inherit methods and properties from other objects. We will focus on only the best two techniques1 for implementing OOP in JavaScript. A JavaScript refresh | TypedArray.org. 3 things I learned about Node.js at Structure 2012 — Cloud Computing News. 5 things they told you not to use in JavaScript. April 24th, 2012 Or, don’t trust what “wise” elders tell you. 1. “Don’t rely on automatic semicolon insertion” Whether you like it or not, whitespace is significant in JavaScript.

A linebreak indicates, in most cases, the end of a statement; a semicolon is automatically inserted for you. 2. Short of making runtimes easier to implement, there’s no compelling reason not to use with. Consider the following code: One of the things that with allows here is to not repeat yourself unnecessarily, which, in my book, is an advantage. 3. Actually, it’s really convenient to be able to reference the currently called function this way, for example if you want to do a recursive call (as an alternative you can give your function a name). Strict mode is great if you really know what you’re doing, but if you do so, you don’t need to use strict mode (I call it “straight-jacket mode”, personally). 4.

Sure, but what does “proprietary” mean anyway? 5. So what? An Open Letter to JavaScript Leaders Regarding Semicolons. I got this email last night from Sean Silva: I was browsing the code for your npm.js project (this file in particular: and noticed you using a style where you line up your commas under the ‘r’ of your var statements, and under your [ and { in array/object literals. I’m very fond of this kind of formatting, but have been reluctant to use it since most js resources expound a fear of js’s automatic semicolon insertion wreaking havoc on your code if you don’t end lines with something which implies a continuation. Is this safe to place commas like this in browser code, or is it just node where this is possible? 2011-12-20 updated link to file I wrote a few paragraphs, and then decided to shorten it to just this response: Yes, it’s quite safe, and perfectly valid JS that every browser understands.

Closure compiler, yuicompressor, packer, and jsmin all can properly minify it. Inimino posted this very clear explanation. The Rules. Mojito - Yahoo! Cocktails. Dublin Tech: Javascript language a- z cheat sheet. Here is an A - Z list of some Javascript idioms and patterns. The idea is to convey in simple terms some features of the actual Javascript language (rather than how it can interact with DOM).

Enjoy... Array Literals An array literal can be defined using a comma separated list in square brackets. Arrays in javascript have a wide selection methods including push() and pop(). Suppose the world got taken over by a dictator who wanted to get rid of the last month of the year? In the example above, the chanceCivilisationCallback callback function is invoked by peakOil. Configuration Object Instead of passing around a bunch of related properties...

Use a configuration object The use of a configuration object makes it makes it easier to write clean APIs that don't need to take a huge long list of parameters. Note: The closure is the object literal returned from annoymous function. The convention is that constructor functions should begin with a capital letter. Now for some planets. Then...