« first day (3508 days earlier)      last day (1431 days later) » 

4:39 AM
is this good way to write js code <a href="javascript:history.back()"> Click Me</a>
 
 
3 hours later…
7:55 AM
@NIKHILCHANDRAROY I personally don't like that at all. Others do accept putting JS code in the href attribute. My personal gripe is that I prefer the logic to be separated. If I have JS code, it should be in a JS file. 1. It ensures I can use JS tools to analyse and refactor the code easily 2. I don't have to constantly flip between the HTML and the JS code to understand the functionality.
One additional thing that really bugs me is that since this is in the href, then trying to open this in a new tab yields nothing at all. I'd much prefer the same page to be opened (with href="#") than opening a completely blank page.
 
 
2 hours later…
9:50 AM
Quite a good read for those interested, seems quora is taking over the actual high profile programmers :P
 
10:18 AM
Does this group welcome questions from Firebase/ Firestore?
 
10:47 AM
@PrashinJeevaganth Should be OK but I'm not sure if anybody is around to answer them. I don't know anything about those, so somebody else should step in
 
I want to ask if anyone knows how to test Firebase cloud functions results on the database using Unit Testing libraries. Currently I know of Jest, but I only know how to use it to test the logic of the functions, not whether the data got populated in the database. I'm using Postman and making HTTP requests manually to test for now.
 
11:24 AM
Just the fact that you're including a database means that you're writing an integration test, rather than a unit test
This is probably fine, but you're probably really testing Firebase code more than you're testing your own.
There's no real reason why you couldn't write a Jest test for it, something like:
await addDataToFirebase(whatever);

const result = await getDataFromFirebase();

expect(result).toEqual(something);
There's probably some value to that, but there will also probably be flakiness involved, so you need to decide if it's worth it
 
@phenomnomnominal would you recommend Jest over Chai/Mocha or Jasmine for unit testing?
 
I'd recommend it for all testing tbh
The ecosystem is really nice
I used to prefer chai assertions, but it's really just syntactic niceness without much benefit
 
OK, I'll try to change over to it. For now I've been setting up Chai/Mocha but mostly because it's the first one I found with a convenient setup guide. I've used Jasmine in the past with Karma.
How is Jest with testing TS code?
 
Really easy. You just add ts-jest and most of it works.
 
11:40 AM
OK, thanks. I added myself a task to change over for my personal projects
 
@phenomnomnominal Oh ok I see, I didnt really know what it was like to do integration tests with a database previously, so was unfamiliar with the form
If I'm doing a purely node project with just a backend, what will be the minimum essential testing you recommend to do?
I wanted to do something like TDD, bc I'm guilty of not doing it early with my previous projects, wanted to do something the right way this time
 
Super hard question to answer
I don't really write unit tests anymore
Most of my tests end up as integration tests, especially over core features/flows
Then I usually add regression tests when I find bugs
I'm awful at TDD
 
Ah ok, I guess I'll just do what I can for now, my supervisor hasn't really gave me good details on the scope of my responsibilities in the project
Anyway, are you familiar with firebase rules?
 
I've used it a bit, but from a test POV it shouldn't matter, it's just an implementation detail
 
Hmm, I was playing around with Jest a little and thinking what kind of testing it could do
I didnt know what I needed was integration testing until I asked you
But I also need Firestore security testing, and that can be done with Jest too on the emulators
I kinda asked it as a question, have a feeling the answer is gonna be very stupid, but I asked it anyway to clear it up fast
-1
Q: Firebase Permission denied Error on Firebase emulator

Prashin JeevaganthI am referencing this tutorial for Firestore security rules. I have extracted the code from the repository and it matches that of the video. I changed the setup code to run the firestore.rules instead of firestore-test.rules, and tried running firebase emulators:start and jest ./spec following th...

 
12:04 PM
Ideally your tests form a pyramid. At the bottom, you have unit tests and you have many of them. Then the next layer is simpler integration tests with, say 2-3 components and these would be fewer. The higher up you go, the less tests you have but they are more complex and cover more of the functionality in one go.
That's really the ideal case and I don't think I've seen anybody really achieve this. For long at least.
 
I disagree with that these days
I'm more of a fan of the trophy model
 
12:38 PM
Hello
 
@Deniz 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…
Sam
2:10 PM
Assigning a variable inside a function lasts only for the duration of the function lifecycle... does the same hold true if I use lodash to create a deep clone of a variable? I seem to be experiencing maximum call stack size exceeded errors when repeatedly calling the offending function
const stripAndReturnComponent = (component, keepTag) => {
    let componentCopy = _.cloneDeep(component);
    ...
    return componentCopy
}
 
does the component contain a reference to itself?
 
Sam
I don't think so, here's the code github.com/samjtozer/react-native-jsonschema-swiper/blob/… its a little hack ive put together
The entry point is the Index variable and forwardRef calls into MockHTMLForm
 
I'd guess that you have a circular reference somewhere
 
Sam
What is the significance of the deep copy here? It seems that if I remove this, I don't get the stack errors.
 
 
2 hours later…
3:59 PM
Hello is anyone there, I have a question regarding creating a web game (multiplayer)
I am thinking that javascript can it be done with simple javascript
I have looked a bit and saw that I may need nodejs + websocket
 
4:11 PM
@Sam a deep copy will follow each reference and copy all their contents. If you are only doing a shallow copy, you might not go into the circular reference . So, if you have something like a = {b : {}}; a.b.c = a, then a shallow copy will not need to re-clone a`.
@jeea you need some sort of server, most likely, in order to coordinate players. Websockets is not required to do the linking but it's a very good solution, as you most likely need real-time synchronisation. However, it does depend on the type of multiplayer game - a slower paced turn-based game can happily need a sync once every 1-5 minutes, for example.
 
@jeea yes you can create a game with js
 
If you can do a P2P communication, you might even avoid the need for Node.js and just do all through the browser.
 
^
 
Basically I know nothing about networks or server and other things, so does it mean that I have to buy some server or what does server means
 
Ok
well do some research and then ask about what you don't understand
 
4:18 PM
ok
 
4:59 PM
@jeea to put it simply, a server is a central location that each client needs to communicate with. A lot of multiplayer games run on this principle - players connect to a server, then each player does stuff and informs the server what they did. They moved left, for example. The server tracks that information from all players and then also sends it to all players. So if you moved left and there was somebody there, you'd bump into them.
 
RKS
5:49 PM
we had fortify scan ran for our code and showed the below vulnerabilty in our spring boot project:'Hardcoded domain in html' The html has the below 3 lines, in that one of the url is hardcoded. Now the question is how to fix this issue and read out of a variable and replace this value in html of a spring boot java app? <script type="text/javascript" src="../shared/js/ui-bootstrap-tpls.js"></script>
<script type="text/javascript" src="../shared/js/angular-route.js"></script>
<script type="text/javascript" src="https://myserver.net"></script>
 
@RKS 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.
 
RKS
we had fortify scan ran for our code and showed the below vulnerabilty in our spring boot project:'Hardcoded domain in html' The html has the below 3 lines, in that one of the url is hardcoded. Now the question is how to fix this issue and read out of a variable and replace this value in html of a spring boot java app? <script type="text/javascript" src="../shared/js/ui-bootstrap-tpls.js"></script>
<script type="text/javascript" src="../shared/js/angular-route.js"></script>
<script type="text/javascript" src="https://myserver.net"></script>When i launch the link myserver.net from browser it
 
6:20 PM
Hi everyone, I am working on a react app. It has a state say stateA and another state stateB which can be computed only by stateA. But stateB is used not in just render() but in other functions as well. How can I keep stateB outside state, yet use it?
I don't want to recompute it again and again. And as stateA would be async because of setState, so I am wondering if stateB is plain JS object, won't it be out of sync from stateA?
 
6:52 PM
Hmm anyone got a neat way to merge two arrays but keeping them "ordered" as in:
`merge([l1, l2, l3, l4], [r1, r2, r3, r4]) === [l1, r1, l2, r2, l3, r3, l4, r4]`
 
@paul23 you seem to mean "interleave", since the order is not exactly preserved.
13
Q: Merge Two Arrays so that the Values Alternate

UndistractionI'm looking for a jQuery method to merge two arrays so that their values alternate: var array1 = [1,2,3,4,5]; var array2 = ['a', 'b', 'c', 'd', 'e']; The result I want is: var arrayCombined = [1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e']; Please note that I know it is trivial to do this in JS, h...

 
jquery, that's an old answer :P
I feel like there should be a parser going over stackoverflow and reopening all questions which have jquery as accepted answer :P
 
7:23 PM
@paul23 yeah, I saw it wasn't a terribly new thing although there were some newer non-jQuery answers. I also added one using generators
 
 
1 hour later…
8:26 PM
oh that look better...
 

« first day (3508 days earlier)      last day (1431 days later) »