I have a problem when it .find()doesn’t work in my Chrome browser, when I use it in AngularJS. This was my original question: AngularJS: Array.prototype.find () does not work in Chrome
It does not work on this line:
console.log($scope.products_colors); // prints `[Object]0: Objectlength: 1__proto__: Array[0]concat: function concat() { [native code] }constructor: function Array() { [native code] }every: function every() { [native code] }filter: function filter() { [native code] }forEach: function forEach() { [native code] }indexOf: function indexOf() { [native code] }join: function join() { [native code] }lastIndexOf: function lastIndexOf() { [native code] }length: 0map: function map() { [native code] }pop: function pop() { [native code] }push: function push() { [native code] }reduce: function reduce() { [native code] }reduceRight: function reduceRight() { [native code] }reverse: function reverse() { [native code] }shift: function shift() { [native code] }slice: function slice() { [native code] }some: function some() { [native code] }sort: function sort() { [native code] }splice: function splice() { [native code] }toLocaleString: function toLocaleString() { [native code] }toString: function toString() { [native code] }unshift: function unshift() { [native code] }__proto__: Object mens_detail_controller.js?body=1:24`
$scope.selected_color = $scope.products_colors.find(function(el) {
return el.id == 91;
});
I know that it does not work on .find, because the code works when I replace it with something else.
Is there an alternative to viewing an array and capturing the first element with a specific condition in javascript?
source
share