This file contains 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
(function() { | |
var a = b = 5; | |
})(); | |
console.log(b); | |
// 1. What will be printed on the console? | |
// 2. Rewrite the code to return the same result but with the variable declarations separated | |
// 3. Enable strict mode to explicitly reference the scope |
This file contains 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
window.onerror = function(message, file, line, column, error) { | |
error = error || {}; | |
$.ajax({ | |
method: 'POST', | |
url: 'https://yourapp.com/path/to/error/log', | |
data: JSON.stringify({ | |
message: message, | |
file: file, | |
line: line, | |
column: column, |
This file contains 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 text ="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; | |
var counter = text.split(" ").reduce(function(total, item){ | |
total[item] = total.hasOwnProperty(item) ? ++total[item] : 1; | |
return total; | |
}, {}); | |
console.log(counter); |
This file contains 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 (!Array.prototype.spliceArray) { | |
Array.prototype.spliceArray = function(index, n, array) { | |
return Array.prototype.splice.apply(this, [index, n].concat(array)); | |
} | |
} |
This file contains 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 a = [1,2,3,4,5,6,7,7,7,7,7,8]; | |
a = a.filter(function(item, pos) { | |
return a.indexOf(item) == pos; | |
}); |