find an object in an array of objects javascript
let arr = [
{ name:"string 1", value:"this", other: "that" },
{ name:"string 2", value:"this", other: "that" }
];
let obj = arr.find(o => o.name === 'string 1');
console.log(obj);
find an object in an array of objects javascript
let arr = [
{ name:"string 1", value:"this", other: "that" },
{ name:"string 2", value:"this", other: "that" }
];
let obj = arr.find(o => o.name === 'string 1');
console.log(obj);
javascript array-like object
function Arraylike(... args) {
this.xarg = args;
this.slice = function(num) {
return new Arraylike(...this.xarg.slice(num));
};
this.splice = function(... args) {
console.error("Splice is not implemented for now.");
};
this.toArray = function() {
return this.xarg;
};
this.length = this.xarg.length;
for(let i = 0; i < this.xarg.length; i++) {
this[i] = this.xarg[i];
}
}
Array.prototype.toArraylike = function() {
return new Arraylike(...this);
};
let yourobject = new Arraylike("whatever", "goes", "here");
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us