From currying to closures there are quite a number of special words used in JavaScript. These will not only help you increase your vocabulary but also better understand JavaScript. Special terms are normally found in documentation and technical articles. But some of them like closures are pretty standard things to know about. Knowing what the word itself means can help you know the concept it's named for better.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "core.css"; | |
@import "theme.css"; | |
@import "user-theme.css"; | |
@import "small-breakpoint.css" (max-width: 40em); | |
@import "landscape.css" screen and (orientation: landscape); | |
@import "print.css" print; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// var last = arr.reverse()[0]; | |
Array.prototype.last = function () { return this.length > 0 ? this[this.length -1] : undefined }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
li { | |
display: none; | |
} | |
/* select items 1 through 3 and show them */ | |
li:nth-child(-n+3) { | |
display: block; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(/p.*g/.test('programming')); // true | |
console.log(/p.*g/.test('pickles')); // false | |
var re = /quick\s(brown).+?(jumps)/ig; | |
var result = re.exec( | |
'The Quick Brown Fox Jumps Over The Lazy Dog' | |
); | |
console.log(result); | |
// ["Quick Brown Fox Jumps", "Brown", "Jumps"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list1 = [2, 4, 5, 6]; | |
var list2 = [3, 5, 8, 9]; | |
merged_list = merge_sorted_list(list1, list2); | |
alert(merged_list); | |
function merge_sorted_list(list1, list2) { | |
merged_list = list1.concat(list2); | |
return merged_list.sort(numsort); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = [ | |
2, -4, | |
6, -9, [8, 9, -6], | |
12, [45, 3, 7], -34, [7, -2] | |
]; | |
sublists = []; | |
sublists_sum = []; | |
for (var i in list) { | |
if (Object.prototype.toString.call(list[i]) == '[object Array]') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input_str = 'madam'; | |
function checkIfPalindrome(str) { | |
if (str == str.split('').reverse().join('')) { | |
alert('Yup, ' + str + 'is a palindrome'); | |
} else { | |
alert('Nope, ' + str + ' isn\'t a palindrome'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (content.length > 300) { | |
// truncate to a shorter text length | |
return content.substring(0, 200) + '...'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style contenteditable> | |
* { | |
display: block; | |
} | |
</style> |