JAVASCRIPT NOW


EDITOR'S PICKS

JAVASCRIPT NOW hopes to help beginner front end developers learn the JavaScript concepts they need, and to pick up additional JavaScript based front-end tricks along the way.

Functions

function addNums(numOne, numTwo) {
        return numOne + numTwo;
    }

console.log(addNums(2, 2));

Functions are chunks of functionality we declare for later use. Like in this example we have created an addNums() function, to take two numbers and return the sum of those numbers to us. numOne, and numTwo are parameters, meaning they are variables that will only exist inside the scope of the function, and they will assist us with the logic we need to perform. Since those variables are contained in the functions scope, when the function finishes it's execution, those variables are destroyed.

Objects

let cat = {
                    name: 'Quin',
                    breed: 'tortoiseshell',
                    age: 5,
                    isCute: true,
                }

In the simplest of terms, an object is a collection of properties. A property is a key to value relationship. Like name, and the string 'Quin'. The cat object has a property with a key of 'name', that has the value of 'Quin'. Objects properties can have a value of any data type, even another object! Objects are very popular in holding together lots of varied, but related data, and they come with many built in methods for working with them. The MDN docs will have more information for you!

Arrays


let instructors = [ 'Autumn', 'Dave'', 'Alecx' ];
    
console.log(instructors[2]);

An array in JavaScript as actually a very special object! Arrays take data of any type, but they have no keys. Instead, to access that information again, we use array indexing. Where we assume the first position in the array is the 0 index, and each item onward increments by one. Arrays also come with a lot of special methods that we can use on them. The MDN docs have lots of helpful information on arrays too!