Get unspecific object by identifying its key value [duplicate]












0
















This question already has an answer here:




  • Find object by id in an array of JavaScript objects

    30 answers



  • Self-references in object literals / initializers

    21 answers




I'm trying to figure out the best way return an object found as a key's value, based upon the given unique key...



export const userAccounts = [
{
uniqueKey: 1,
username: 'Guest',
password: 'guest',
thumbnailUrl: 'default'
},
{
uniqueKey: 2,
username: 'philzcoffee',
password: 'hotCup123',
thumbnailUrl: 'https//myImages.com/myImagephilzcoffee.jpg'
},
{
uniqueKey: 3,
username: 'fortnite',
password: 'shooter234',
thumbnailUrl: 'https//myImages.com/myImageFortnite.jpg'
},
{
uniqueKey: 4,
username: 'playhearthstone',
password: 'cards345',
thumbnailUrl: 'https//myImages.com/myImagePlayhearthstone.jpg'
},
{
uniqueKey: 5,
username: 'George Costanza',
password: 'creator',
thumbnailUrl: 'default'
},
{
uniqueKey: 6,
username: 'biancasaurus',
password: 'pass1',
thumbnailUrl: 'default'
},
{
uniqueKey: 7,
username: 'martinseludo',
password: 'pass2',
thumbnailUrl: 'default'
},
{
uniqueKey: 8,
username: 'michaelmarzetta',
password: 'pass3',
thumbnailUrl: 'default'
},
{
uniqueKey: 9,
username: 'themexican_leprechaun',
password: 'pass4',
thumbnailUrl: 'default'
},
{
uniqueKey: 10,
username: 'dennis_futbol',
password: 'pass5',
thumbnailUrl: 'default'
},
{
uniqueKey: 11,
username: 'awaywetravel',
password: 'pass6',
thumbnailUrl: 'default'
},
{
uniqueKey: 12,
username: 'awesomebt28',
password: 'pass7',
thumbnailUrl: 'default'
},
];




let philzcoffee = userAccounts.find(user => user.uniqueKey === 2);
let fortnite = userAccounts.find(user => user.uniqueKey === 3);
let playhearthstone = userAccounts.find(user => user.uniqueKey === 4);
export const userPosts = [
{
postOwner: philzcoffee,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/69cf901b-f96d-466e-a745-ff2a01effac9_philz-image.jpg",
likes: 400,
timestamp: "July 17th 2017, 12:42:40 pm",
comments: [
{
username: "philzcoffee",
timestamp: "July 17th 2017, 12:42:40 pm",
text:
"We've got more than just delicious coffees to offer at our shops!"
},
{
username: "biancasaurus",
timestamp: "July 17th 2017, 1:00:32 pm",
text: "Looks delicious!"
},
{
username: "martinseludo",
timestamp: "July 17th 2017, 1:02:45 pm",
text: "Can't wait to try it!"
}
]
},
{
postOwner: fortnite,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/89d13918-b7a2-4b40-9658-f376ea3f6b59_37131538_213683546146400_1083714364399157248_n.jpg",
likes: 4307,
timestamp: "July 15th 2017, 03:12:09 pm",
comments: [
{
username: "twitch",
timestamp: "July 15th 2017, 03:12:21 pm",
text: "Epic Street Fighter action here in Las Vegas at #EVO2017!"
},
{
username: "michaelmarzetta",
timestamp: "July 15th 2017, 03:14:09 pm",
text: "Omg that match was crazy"
},
{
username: "themexican_leprechaun",
timestamp: "July 15th 2017, 03:32:52 pm",
text: "What a setup"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:44 pm",
text: "It that injustice"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:55 pm",
text: "Is"
}
]
},
{
postOwner: playhearthstone,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/43bf01f9-319c-469d-8cf5-0120fe1007f1_yosemite.jpg",
likes: 5306,
timestamp: "July 14th 2017, 10:04:08 am",
comments: [
{
username: "playhearthstone",
timestamp: "July 14th 2017, 10:04:08 am",
text: "Love this shot!"
},
{
username: "awaywetravel",
timestamp: "July 15th 2017, 11:52:13 am",
text: "Yosemite is my most favorite place in the universe"
},
{
username: "awesomebt28",
timestamp: "July 15th 2017, 12:16:31 pm",
text: "I like how Half Dome looks so old and useless"
}
]
}
];


With this code I get the following error postOwner is not defined. I'm guessing this is because the postOwner: userAccounts.filter(...) call is returning an array with the object as an element.



Instead... I just want to return the object itself, that was found from the entered uniqueKey.



Any idea how to do this?



Edit: made changes in code to match suggestions given in comments below, but still receiving the same error...










share|improve this question















marked as duplicate by T.J. Crowder javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 18:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • That's not how JavaScript and objects work.

    – Andreas
    Nov 20 '18 at 18:14











  • Why you're using .filter() at all? With the given example userAccounts.filter(user => user.uniqueKey === x) === userAccounts[x - 1]

    – Andreas
    Nov 20 '18 at 18:15













  • Both of the linked questions relate to what you're trying to do. Yes, filter returns an array; to just get the (first) match, use find (that's the first question). You can't refer to the postOwner property on the object in a subsequent property initializer on the same object (that's the second question). (cont'd)

    – T.J. Crowder
    Nov 20 '18 at 18:18













  • (continuing) ...so you'll need to have a postOwner variable prior to userPosts which is the result of finding the owner, and then use that in your userPosts initializer.

    – T.J. Crowder
    Nov 20 '18 at 18:20











  • I've tried the following on sandbox, but am not getting a console log of the username... codepen.io/jamespagedev/pen/yQpVRv?editors=0011

    – Fiddle Freak
    Nov 20 '18 at 18:26
















0
















This question already has an answer here:




  • Find object by id in an array of JavaScript objects

    30 answers



  • Self-references in object literals / initializers

    21 answers




I'm trying to figure out the best way return an object found as a key's value, based upon the given unique key...



export const userAccounts = [
{
uniqueKey: 1,
username: 'Guest',
password: 'guest',
thumbnailUrl: 'default'
},
{
uniqueKey: 2,
username: 'philzcoffee',
password: 'hotCup123',
thumbnailUrl: 'https//myImages.com/myImagephilzcoffee.jpg'
},
{
uniqueKey: 3,
username: 'fortnite',
password: 'shooter234',
thumbnailUrl: 'https//myImages.com/myImageFortnite.jpg'
},
{
uniqueKey: 4,
username: 'playhearthstone',
password: 'cards345',
thumbnailUrl: 'https//myImages.com/myImagePlayhearthstone.jpg'
},
{
uniqueKey: 5,
username: 'George Costanza',
password: 'creator',
thumbnailUrl: 'default'
},
{
uniqueKey: 6,
username: 'biancasaurus',
password: 'pass1',
thumbnailUrl: 'default'
},
{
uniqueKey: 7,
username: 'martinseludo',
password: 'pass2',
thumbnailUrl: 'default'
},
{
uniqueKey: 8,
username: 'michaelmarzetta',
password: 'pass3',
thumbnailUrl: 'default'
},
{
uniqueKey: 9,
username: 'themexican_leprechaun',
password: 'pass4',
thumbnailUrl: 'default'
},
{
uniqueKey: 10,
username: 'dennis_futbol',
password: 'pass5',
thumbnailUrl: 'default'
},
{
uniqueKey: 11,
username: 'awaywetravel',
password: 'pass6',
thumbnailUrl: 'default'
},
{
uniqueKey: 12,
username: 'awesomebt28',
password: 'pass7',
thumbnailUrl: 'default'
},
];




let philzcoffee = userAccounts.find(user => user.uniqueKey === 2);
let fortnite = userAccounts.find(user => user.uniqueKey === 3);
let playhearthstone = userAccounts.find(user => user.uniqueKey === 4);
export const userPosts = [
{
postOwner: philzcoffee,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/69cf901b-f96d-466e-a745-ff2a01effac9_philz-image.jpg",
likes: 400,
timestamp: "July 17th 2017, 12:42:40 pm",
comments: [
{
username: "philzcoffee",
timestamp: "July 17th 2017, 12:42:40 pm",
text:
"We've got more than just delicious coffees to offer at our shops!"
},
{
username: "biancasaurus",
timestamp: "July 17th 2017, 1:00:32 pm",
text: "Looks delicious!"
},
{
username: "martinseludo",
timestamp: "July 17th 2017, 1:02:45 pm",
text: "Can't wait to try it!"
}
]
},
{
postOwner: fortnite,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/89d13918-b7a2-4b40-9658-f376ea3f6b59_37131538_213683546146400_1083714364399157248_n.jpg",
likes: 4307,
timestamp: "July 15th 2017, 03:12:09 pm",
comments: [
{
username: "twitch",
timestamp: "July 15th 2017, 03:12:21 pm",
text: "Epic Street Fighter action here in Las Vegas at #EVO2017!"
},
{
username: "michaelmarzetta",
timestamp: "July 15th 2017, 03:14:09 pm",
text: "Omg that match was crazy"
},
{
username: "themexican_leprechaun",
timestamp: "July 15th 2017, 03:32:52 pm",
text: "What a setup"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:44 pm",
text: "It that injustice"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:55 pm",
text: "Is"
}
]
},
{
postOwner: playhearthstone,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/43bf01f9-319c-469d-8cf5-0120fe1007f1_yosemite.jpg",
likes: 5306,
timestamp: "July 14th 2017, 10:04:08 am",
comments: [
{
username: "playhearthstone",
timestamp: "July 14th 2017, 10:04:08 am",
text: "Love this shot!"
},
{
username: "awaywetravel",
timestamp: "July 15th 2017, 11:52:13 am",
text: "Yosemite is my most favorite place in the universe"
},
{
username: "awesomebt28",
timestamp: "July 15th 2017, 12:16:31 pm",
text: "I like how Half Dome looks so old and useless"
}
]
}
];


With this code I get the following error postOwner is not defined. I'm guessing this is because the postOwner: userAccounts.filter(...) call is returning an array with the object as an element.



Instead... I just want to return the object itself, that was found from the entered uniqueKey.



Any idea how to do this?



Edit: made changes in code to match suggestions given in comments below, but still receiving the same error...










share|improve this question















marked as duplicate by T.J. Crowder javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 18:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • That's not how JavaScript and objects work.

    – Andreas
    Nov 20 '18 at 18:14











  • Why you're using .filter() at all? With the given example userAccounts.filter(user => user.uniqueKey === x) === userAccounts[x - 1]

    – Andreas
    Nov 20 '18 at 18:15













  • Both of the linked questions relate to what you're trying to do. Yes, filter returns an array; to just get the (first) match, use find (that's the first question). You can't refer to the postOwner property on the object in a subsequent property initializer on the same object (that's the second question). (cont'd)

    – T.J. Crowder
    Nov 20 '18 at 18:18













  • (continuing) ...so you'll need to have a postOwner variable prior to userPosts which is the result of finding the owner, and then use that in your userPosts initializer.

    – T.J. Crowder
    Nov 20 '18 at 18:20











  • I've tried the following on sandbox, but am not getting a console log of the username... codepen.io/jamespagedev/pen/yQpVRv?editors=0011

    – Fiddle Freak
    Nov 20 '18 at 18:26














0












0








0









This question already has an answer here:




  • Find object by id in an array of JavaScript objects

    30 answers



  • Self-references in object literals / initializers

    21 answers




I'm trying to figure out the best way return an object found as a key's value, based upon the given unique key...



export const userAccounts = [
{
uniqueKey: 1,
username: 'Guest',
password: 'guest',
thumbnailUrl: 'default'
},
{
uniqueKey: 2,
username: 'philzcoffee',
password: 'hotCup123',
thumbnailUrl: 'https//myImages.com/myImagephilzcoffee.jpg'
},
{
uniqueKey: 3,
username: 'fortnite',
password: 'shooter234',
thumbnailUrl: 'https//myImages.com/myImageFortnite.jpg'
},
{
uniqueKey: 4,
username: 'playhearthstone',
password: 'cards345',
thumbnailUrl: 'https//myImages.com/myImagePlayhearthstone.jpg'
},
{
uniqueKey: 5,
username: 'George Costanza',
password: 'creator',
thumbnailUrl: 'default'
},
{
uniqueKey: 6,
username: 'biancasaurus',
password: 'pass1',
thumbnailUrl: 'default'
},
{
uniqueKey: 7,
username: 'martinseludo',
password: 'pass2',
thumbnailUrl: 'default'
},
{
uniqueKey: 8,
username: 'michaelmarzetta',
password: 'pass3',
thumbnailUrl: 'default'
},
{
uniqueKey: 9,
username: 'themexican_leprechaun',
password: 'pass4',
thumbnailUrl: 'default'
},
{
uniqueKey: 10,
username: 'dennis_futbol',
password: 'pass5',
thumbnailUrl: 'default'
},
{
uniqueKey: 11,
username: 'awaywetravel',
password: 'pass6',
thumbnailUrl: 'default'
},
{
uniqueKey: 12,
username: 'awesomebt28',
password: 'pass7',
thumbnailUrl: 'default'
},
];




let philzcoffee = userAccounts.find(user => user.uniqueKey === 2);
let fortnite = userAccounts.find(user => user.uniqueKey === 3);
let playhearthstone = userAccounts.find(user => user.uniqueKey === 4);
export const userPosts = [
{
postOwner: philzcoffee,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/69cf901b-f96d-466e-a745-ff2a01effac9_philz-image.jpg",
likes: 400,
timestamp: "July 17th 2017, 12:42:40 pm",
comments: [
{
username: "philzcoffee",
timestamp: "July 17th 2017, 12:42:40 pm",
text:
"We've got more than just delicious coffees to offer at our shops!"
},
{
username: "biancasaurus",
timestamp: "July 17th 2017, 1:00:32 pm",
text: "Looks delicious!"
},
{
username: "martinseludo",
timestamp: "July 17th 2017, 1:02:45 pm",
text: "Can't wait to try it!"
}
]
},
{
postOwner: fortnite,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/89d13918-b7a2-4b40-9658-f376ea3f6b59_37131538_213683546146400_1083714364399157248_n.jpg",
likes: 4307,
timestamp: "July 15th 2017, 03:12:09 pm",
comments: [
{
username: "twitch",
timestamp: "July 15th 2017, 03:12:21 pm",
text: "Epic Street Fighter action here in Las Vegas at #EVO2017!"
},
{
username: "michaelmarzetta",
timestamp: "July 15th 2017, 03:14:09 pm",
text: "Omg that match was crazy"
},
{
username: "themexican_leprechaun",
timestamp: "July 15th 2017, 03:32:52 pm",
text: "What a setup"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:44 pm",
text: "It that injustice"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:55 pm",
text: "Is"
}
]
},
{
postOwner: playhearthstone,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/43bf01f9-319c-469d-8cf5-0120fe1007f1_yosemite.jpg",
likes: 5306,
timestamp: "July 14th 2017, 10:04:08 am",
comments: [
{
username: "playhearthstone",
timestamp: "July 14th 2017, 10:04:08 am",
text: "Love this shot!"
},
{
username: "awaywetravel",
timestamp: "July 15th 2017, 11:52:13 am",
text: "Yosemite is my most favorite place in the universe"
},
{
username: "awesomebt28",
timestamp: "July 15th 2017, 12:16:31 pm",
text: "I like how Half Dome looks so old and useless"
}
]
}
];


With this code I get the following error postOwner is not defined. I'm guessing this is because the postOwner: userAccounts.filter(...) call is returning an array with the object as an element.



Instead... I just want to return the object itself, that was found from the entered uniqueKey.



Any idea how to do this?



Edit: made changes in code to match suggestions given in comments below, but still receiving the same error...










share|improve this question

















This question already has an answer here:




  • Find object by id in an array of JavaScript objects

    30 answers



  • Self-references in object literals / initializers

    21 answers




I'm trying to figure out the best way return an object found as a key's value, based upon the given unique key...



export const userAccounts = [
{
uniqueKey: 1,
username: 'Guest',
password: 'guest',
thumbnailUrl: 'default'
},
{
uniqueKey: 2,
username: 'philzcoffee',
password: 'hotCup123',
thumbnailUrl: 'https//myImages.com/myImagephilzcoffee.jpg'
},
{
uniqueKey: 3,
username: 'fortnite',
password: 'shooter234',
thumbnailUrl: 'https//myImages.com/myImageFortnite.jpg'
},
{
uniqueKey: 4,
username: 'playhearthstone',
password: 'cards345',
thumbnailUrl: 'https//myImages.com/myImagePlayhearthstone.jpg'
},
{
uniqueKey: 5,
username: 'George Costanza',
password: 'creator',
thumbnailUrl: 'default'
},
{
uniqueKey: 6,
username: 'biancasaurus',
password: 'pass1',
thumbnailUrl: 'default'
},
{
uniqueKey: 7,
username: 'martinseludo',
password: 'pass2',
thumbnailUrl: 'default'
},
{
uniqueKey: 8,
username: 'michaelmarzetta',
password: 'pass3',
thumbnailUrl: 'default'
},
{
uniqueKey: 9,
username: 'themexican_leprechaun',
password: 'pass4',
thumbnailUrl: 'default'
},
{
uniqueKey: 10,
username: 'dennis_futbol',
password: 'pass5',
thumbnailUrl: 'default'
},
{
uniqueKey: 11,
username: 'awaywetravel',
password: 'pass6',
thumbnailUrl: 'default'
},
{
uniqueKey: 12,
username: 'awesomebt28',
password: 'pass7',
thumbnailUrl: 'default'
},
];




let philzcoffee = userAccounts.find(user => user.uniqueKey === 2);
let fortnite = userAccounts.find(user => user.uniqueKey === 3);
let playhearthstone = userAccounts.find(user => user.uniqueKey === 4);
export const userPosts = [
{
postOwner: philzcoffee,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/69cf901b-f96d-466e-a745-ff2a01effac9_philz-image.jpg",
likes: 400,
timestamp: "July 17th 2017, 12:42:40 pm",
comments: [
{
username: "philzcoffee",
timestamp: "July 17th 2017, 12:42:40 pm",
text:
"We've got more than just delicious coffees to offer at our shops!"
},
{
username: "biancasaurus",
timestamp: "July 17th 2017, 1:00:32 pm",
text: "Looks delicious!"
},
{
username: "martinseludo",
timestamp: "July 17th 2017, 1:02:45 pm",
text: "Can't wait to try it!"
}
]
},
{
postOwner: fortnite,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/89d13918-b7a2-4b40-9658-f376ea3f6b59_37131538_213683546146400_1083714364399157248_n.jpg",
likes: 4307,
timestamp: "July 15th 2017, 03:12:09 pm",
comments: [
{
username: "twitch",
timestamp: "July 15th 2017, 03:12:21 pm",
text: "Epic Street Fighter action here in Las Vegas at #EVO2017!"
},
{
username: "michaelmarzetta",
timestamp: "July 15th 2017, 03:14:09 pm",
text: "Omg that match was crazy"
},
{
username: "themexican_leprechaun",
timestamp: "July 15th 2017, 03:32:52 pm",
text: "What a setup"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:44 pm",
text: "It that injustice"
},
{
username: "dennis_futbol",
timestamp: "July 15th 2017, 04:23:55 pm",
text: "Is"
}
]
},
{
postOwner: playhearthstone,
username: postOwner.username,
password: postOwner.password,
thumbnailUrl: postOwner.thumbnailUrl,
imageUrl:
"https://tk-assets.lambdaschool.com/43bf01f9-319c-469d-8cf5-0120fe1007f1_yosemite.jpg",
likes: 5306,
timestamp: "July 14th 2017, 10:04:08 am",
comments: [
{
username: "playhearthstone",
timestamp: "July 14th 2017, 10:04:08 am",
text: "Love this shot!"
},
{
username: "awaywetravel",
timestamp: "July 15th 2017, 11:52:13 am",
text: "Yosemite is my most favorite place in the universe"
},
{
username: "awesomebt28",
timestamp: "July 15th 2017, 12:16:31 pm",
text: "I like how Half Dome looks so old and useless"
}
]
}
];


With this code I get the following error postOwner is not defined. I'm guessing this is because the postOwner: userAccounts.filter(...) call is returning an array with the object as an element.



Instead... I just want to return the object itself, that was found from the entered uniqueKey.



Any idea how to do this?



Edit: made changes in code to match suggestions given in comments below, but still receiving the same error...





This question already has an answer here:




  • Find object by id in an array of JavaScript objects

    30 answers



  • Self-references in object literals / initializers

    21 answers








javascript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 18:39







Fiddle Freak

















asked Nov 20 '18 at 18:11









Fiddle FreakFiddle Freak

7411532




7411532




marked as duplicate by T.J. Crowder javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 18:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by T.J. Crowder javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 18:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • That's not how JavaScript and objects work.

    – Andreas
    Nov 20 '18 at 18:14











  • Why you're using .filter() at all? With the given example userAccounts.filter(user => user.uniqueKey === x) === userAccounts[x - 1]

    – Andreas
    Nov 20 '18 at 18:15













  • Both of the linked questions relate to what you're trying to do. Yes, filter returns an array; to just get the (first) match, use find (that's the first question). You can't refer to the postOwner property on the object in a subsequent property initializer on the same object (that's the second question). (cont'd)

    – T.J. Crowder
    Nov 20 '18 at 18:18













  • (continuing) ...so you'll need to have a postOwner variable prior to userPosts which is the result of finding the owner, and then use that in your userPosts initializer.

    – T.J. Crowder
    Nov 20 '18 at 18:20











  • I've tried the following on sandbox, but am not getting a console log of the username... codepen.io/jamespagedev/pen/yQpVRv?editors=0011

    – Fiddle Freak
    Nov 20 '18 at 18:26



















  • That's not how JavaScript and objects work.

    – Andreas
    Nov 20 '18 at 18:14











  • Why you're using .filter() at all? With the given example userAccounts.filter(user => user.uniqueKey === x) === userAccounts[x - 1]

    – Andreas
    Nov 20 '18 at 18:15













  • Both of the linked questions relate to what you're trying to do. Yes, filter returns an array; to just get the (first) match, use find (that's the first question). You can't refer to the postOwner property on the object in a subsequent property initializer on the same object (that's the second question). (cont'd)

    – T.J. Crowder
    Nov 20 '18 at 18:18













  • (continuing) ...so you'll need to have a postOwner variable prior to userPosts which is the result of finding the owner, and then use that in your userPosts initializer.

    – T.J. Crowder
    Nov 20 '18 at 18:20











  • I've tried the following on sandbox, but am not getting a console log of the username... codepen.io/jamespagedev/pen/yQpVRv?editors=0011

    – Fiddle Freak
    Nov 20 '18 at 18:26

















That's not how JavaScript and objects work.

– Andreas
Nov 20 '18 at 18:14





That's not how JavaScript and objects work.

– Andreas
Nov 20 '18 at 18:14













Why you're using .filter() at all? With the given example userAccounts.filter(user => user.uniqueKey === x) === userAccounts[x - 1]

– Andreas
Nov 20 '18 at 18:15







Why you're using .filter() at all? With the given example userAccounts.filter(user => user.uniqueKey === x) === userAccounts[x - 1]

– Andreas
Nov 20 '18 at 18:15















Both of the linked questions relate to what you're trying to do. Yes, filter returns an array; to just get the (first) match, use find (that's the first question). You can't refer to the postOwner property on the object in a subsequent property initializer on the same object (that's the second question). (cont'd)

– T.J. Crowder
Nov 20 '18 at 18:18







Both of the linked questions relate to what you're trying to do. Yes, filter returns an array; to just get the (first) match, use find (that's the first question). You can't refer to the postOwner property on the object in a subsequent property initializer on the same object (that's the second question). (cont'd)

– T.J. Crowder
Nov 20 '18 at 18:18















(continuing) ...so you'll need to have a postOwner variable prior to userPosts which is the result of finding the owner, and then use that in your userPosts initializer.

– T.J. Crowder
Nov 20 '18 at 18:20





(continuing) ...so you'll need to have a postOwner variable prior to userPosts which is the result of finding the owner, and then use that in your userPosts initializer.

– T.J. Crowder
Nov 20 '18 at 18:20













I've tried the following on sandbox, but am not getting a console log of the username... codepen.io/jamespagedev/pen/yQpVRv?editors=0011

– Fiddle Freak
Nov 20 '18 at 18:26





I've tried the following on sandbox, but am not getting a console log of the username... codepen.io/jamespagedev/pen/yQpVRv?editors=0011

– Fiddle Freak
Nov 20 '18 at 18:26












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?