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.

OOP In JavaScript: What You NEED to Know

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. Building applications with objects allows us to adopt some valuable techniques, namely, Inheritance (objects can inherit features from other objects), Polymorphism (objects can share the same interface—how they are accessed and used—while their underlying implementation of the interface may differ), and Encapsulation (each object is responsible for specific tasks). 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. Lets Code. A JavaScript refresh. 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.

5 things they told you not to use in JavaScript

“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.

An Open Letter to JavaScript Leaders Regarding Semicolons

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. Inimino posted this very clear explanation. I am going to be a bit more opinionated. The Rules In general, \n ends a statement unless: The first is pretty obvious. The second is super weird. Mojito - Yahoo! Cocktails. Dublin Tech: Javascript language a- z cheat sheet. Here is an A - Z list of some Javascript idioms and patterns.

Dublin Tech: Javascript language a- z cheat sheet

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...