JS: Arrays

by kyllle

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.min.css">
<h3>Arrays</h3>

SCSS

@import url(http://fonts.googleapis.com/css?family=Roboto:300,400,500);

* {
  -webkit-font-smoothing: antialiased;
}

body {
    font-family: Roboto;
    font-size: 18px;
    padding: 16px;
    line-height: 1.5;
    font-weight: normal;
    color: #ccc;
    background: #292929;
}

h1, h2, h3 {
    font-weight: normal;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 24px;
}

.pg-heading {
    margin-bottom: 0;
}

a {
    color: #95baf6;
    transition: opacity .3s;
	
	&:hover {
    	opacity: 0.75;
	}
}

Babel + JSX

console.clear();

// Map an array of objects
var people = [
	{
    	title: 'Joe'
    },
    {
    	title: 'Jack'
    },
    {
    	title: 'Paul'
    }
];

people.map(function(person) {
	console.log('Mapped::', person.title);
});


// Concatenate 2 arrays
var people = ['Joe', 'Jack', 'Paul'];
var animals = ['Cat', 'Dog', 'Rabbit']

console.log('Concatenate arrays::', people.concat(animals));