Javascript

I do declare

Declarative vs. Imperative

During one of our classes at The Iron Yard we had a discussion on declarative vs. imperative coding. On short, the primary difference is the basic structure and rhythm of your code. Here's how I understand it:

Alternative For Loops

We commonly use for loops to start at a numerical point and end at a numerical point, but they're not that rigid. In the below example we start with A, and on each loop we're adding B. Pretty cool if you ask me.

This

for (var start ="A"; start.length < 5; start = start + "B") {
    console.log(start)
}

Outputs

> A  
> AB  
> ABB  
> ABBB

Where's my inheritance?

I like working with data. As a graphic designer structured information is like M&Ms to a three year old. Sort all the colours! The lesson I just completed dealt with objects, classes and prototypes and explained inheritance. Being familiar with CSS inheritance and classes were ringing a solid brass bell. Basic inheritance looks something like this:

What is the difference between a function() and a method()

I found myself asking this question because the two seem painfully similar. I found the following answer at Stackoverflow, Andrew Edgecombe explains

A function is a piece of code that is called by name. It can be passed data to operate on (i.e. the parameters) and can optionally return data (the return value).

All data that is passed to a function is explicitly passed.

Pages

Subscribe to RSS - Javascript