Breaking Bad
Trying to break angular.forEach
by Slava Fomin II
CSS
</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<style>
JavaScript
var someData = {
foo: 'Foo',
bar: 'Bar',
baz: 'Baz'
};
alert('Look at the JavaScript console for output!');
console.log('Non-interupted forEach');
angular.forEach(someData, function(value, key) {
console.log(key + ' = ' + value);
});
console.log('Interupted with "return" forEach');
angular.forEach(someData, function(value, key) {
console.log(key + ' = ' + value);
return;
});
console.log('Interupted with "return false" forEach');
angular.forEach(someData, function(value, key) {
console.log(key + ' = ' + value);
return false;
});
console.log('Interupted with "return true" forEach');
angular.forEach(someData, function(value, key) {
console.log(key + ' = ' + value);
return true;
});