« first day (3554 days earlier)      last day (1377 days later) » 

12:27 AM
stackoverflow.com/questions/62805412/… someone help me out please
i feel like every time i have to use javascript, i end up confused and enraged
i just have no idea why this wouldn't work
 
 
5 hours later…
4:59 AM
Hello
Any one here?
 
@mrKindo Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
2 hours later…
6:30 AM
@Gardezi Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
1 message moved to Trash can
 
Hi guys I hope all of you are doing fine. I'm trying to figure out how to convert this function into a one liner function using lodash
  function isSeen(data, userId){
      if (userId === undefined)
       return data.seenByUserIds !== null
      else
       return data.seenByUserIds != null && data.seenByUserIds.indexOf(userId) != -1;
    }
 
@Gardezi not sure why you need lodash. You can already just convert to return data.seenByUserIds != null && data.seenByUserIds.indexOf(userId) != -1; - you check data.seenByUserIds in either case, anyway, so you'll get the same result whether or not userId is undefined. Also, I'd expect data.seenByUserIds to not contain undefined, so in the case of data.seenByUserIds.indexOf(undefined) you should just get -1
 
6:48 AM
@vl
@VLAZ I was trying to achieve something like this

userId ? !lodash.isNil(insight.seenByUserIds) && lodash.includes(insight.seenByUserIds, userId) : !lodash.isNil(insight.seenByUserIds)
 
I don't think that's better. 1. You can already use the conditional operator without Lodash. 2. I hate the conditional operator as it tends to make stuff harder to read and understand. So, if I were to improve your code in terms of length, I'd just remove the conditional branching altogether. The two branches overlap, as I said.
From there, using Lodash is not really that useful isNil is slightly more expressive so you can flip a coin on whether to use it. includes is OK but you can use Array#includes in vanilla.
So, Lodash adds very little here. It's just re-writing the exact same vanilla logic nut using Lodash methods. That's not a very good use case for the library, as it doesn't improve much.
 
7:29 AM
@OmerHijazi Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
@OmerHijazi Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
 
Hi
so i have a form in which ive added an eventlistener
and whenever enter is pressed i dont want it to submit so i added preventdefault()
but that doesnt work at all
its supposed to add <br> to the input whenever enter is pressed
but it adds it then submits
this is my code:
       var input = document.getElementById("msg");
      input.addEventListener("keyup", function(event) {
        if (event.keyCode === 13) {
          event.preventDefault();
          input.value += "<br>"
        }
      });
 
@OmerHijazi Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
wut
 
7:42 AM
hi guys
someone use primeng and know wai aria?
 
can anyone help
 
8:22 AM
@OmerHijazi your code is correct however, you need to use keydown instead of keyup. Here is a demo. The keyup event occurs too late to prevent the submission. It's annoying but at least consistent.
 
 
2 hours later…
9:59 AM
Hi All
facing one issue with the dynamic array adding
promotions[i].[name].push({my Properties here})
this line of code is in a forIn iterator and the value of the name property will be coming from an iterator object
but this is giving me error as identifier expected..
if i do something like this
promotions[i].name.push({my Properties here})

it works fine for me
 
promotions[i].[name] -> promotions[i][name]
 
 
3 hours later…
12:53 PM
To: Ben Fortune,
 
1:14 PM
hey there, anyone know how to use componentDidMount event in styled-component ??
anyone there ??
 
 
1 hour later…
2:24 PM
is it inappropriate to ask for React help in here?
 
@ZeroCool Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
didn't find any room for react, So, it was closest
 
same here
 
this is the correct room for all things javascript
though... the number of people willing/able to answer here has dwindled sharply the past 2 years
 
can you help ??
 
2:27 PM
im trying to add a delete button to a Card. i know react uses something called state but the class im using to display the card doesnt use it
 
depends on the question, i don't really have time to play 100 questions to get to an answerable question, but if i see something I can answer i will
styled c omponents and component did mount aren't things i've really messe dwith
for your delete question, "state" for an app or component doesn't always have to consist of the state features react provides
for example, i usually use mobx as a replacement
so your delete functionality would just need to remove the item from the collection of cards, wherever that collection is
 
i have a different js file for each card, and then am displaying all of them on a separate js file (dashboard.js)
my issue is, the button for closing the card would be inside the card.js file, but the card needs to be removed from the parent so it doesn't display (dashboard.js)
 
yep, you just need to, in one way or another, inform the parent
can be done with a property that accepts a function, an event,
shared state,
 
 
2 hours later…
user8729657
5:05 PM
Anyone know where I can purchase a cheap computer server?
 
5:52 PM
@OvieTrix raspberry pi
idk what you need it for
room topic changed to JavaScript: Topic: Anything JavaScript, ECMAScript including Node, React, Angular, Vue, etc. Read this: javascriptroom.github.io/rules. Before asking inform yourself on the XY problem goo.gl/taIqf | Room meta discussions: github.com/JavaScriptRoom/culture. How to format code in chat: sopython.com/wiki/… [ecmascript] [ecmascript-6] [javascript] [nodejs] [typescript]
 
Wassup my dudes?
 
@Linux4Life531 Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@JamesBot, Cool
I have a json variable that looks something like this: {word: {value: "blaa", hapiness: 9.99}, word: {value: "blaa2", hapiness: 9.89}}. How is it possible that I could find the 2nd words value and hapiness
 
that is an object not JSON
 
6:04 PM
the second word overwrites the first
 
so you can only access the 2 value and happiness
 
||> const obj = {word: {value: "blaa", hapiness: 9.99}, word: {value: "blaa2", hapiness: 9.89}}; return obj.word
 
@JBis {"value":"blaa2","hapiness":9.89} Logged: `` Took: 0ms
 
6:05 PM
So I should do something like this: {word1: {value: "blaa", hapiness: 9.99}, word2: {value: "blaa2", hapiness: 9.89}}
And then access wordN
 
@Linux4Life531 you can but that sucks
use an array
 
KK
How would do that?
 
||> const arr = [{value: "blaa", hapiness: 9.99}, {value: "blaa2", hapiness: 9.89}]; arr[0].hapiness + arr[1].hapiness
 
@JBis 19.880000000000003 Logged: `` Took: 1ms
 
Thanks so much, You are amazing! :D
Can I give an upvote to u or something or just say thx
 
6:08 PM
no upvotes in chat, "thx" works
 
K
Thx a ton tho
:D
 
np
 
U just fixed a problem I have been working on since 2. Thx so much!
 
 
1 hour later…
7:31 PM
Wassup Guys?
I have a string, and I want to get a couple of things from it. For example, I have a large string with R and a number between 1 and 19 after it. For example, R05. I want to extract that from the string. However, there is a chance their could be an R0 somewhere else in the string. How can I do this?
Should I be using a Regex or is this word like R01
Or something else...
 
8:25 PM
@Linux4Life531 sounds like regex would be the best option
 
8:48 PM
@Linux4Life531, \R[01][0-9]\ should do that.
 
@greg-tumolo Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@Linux4Life531, beware: the above will match "R00".
 
9:02 PM
@Linux4Life531, \(R0[123456789]|R1[0-9])\ may do what you want.
 

« first day (3554 days earlier)      last day (1377 days later) »