jQuery(function($) {
var $link = $('.link');
$link.on('click', function(event) {
event.preventDefault();
$link.removeClass('active');
$(this).addClass('active');
});
});
'use strict';
var a = [1,2,3,77,5,6];
var b = [];
for (var i in a) {
b.push(a[i]);
a[i] = (function(i) {
return function() {
return b[i];
};
})(i);
}
console.log(a[3]());
'use strict';
// Plunker may spam in console
console.clear();
// Input string
var string = 'The quick brown fox jumped over the lazy dog.';
// Replacements
var matches = {
'quick': 'slow',
'brown': 'black',
'fox': 'bear'
};
// Gogo
var result = string.replace(
// Match all keys
new RegExp(Object.keys(matches).join('|'), 'g'),
// Just get value from replacements
function(match) {
return matches[match];
}
);
// Bingo
console.log(result);