« first day (3490 days earlier)      last day (1680 days later) » 
00:00 - 20:0020:00 - 23:00

00:10
posted on May 06, 2020 by Ben Mason

Hi, everyone! We've just released Chrome 81 (81.0.4044.138) for Android: it'll become available on Google Play over the next few weeks. You can see a full list of the changes in the Git log. If you find a new issue, please let us know by filing a bug. Ben Mason Google Chrome

Check the `<canvas>` element on the `ctx` context?
Maybe it's not the same one you're seeing on screen?
Oh maybe, use the `closePath` method once you've finished with the `beginPath` method?

I dunno...
 
9 hours later…
09:11
I've a problem in regex replace. I want to match an id and replace it with a string at the position in an array that the match indicates
Eg
a = ['abc','xyz','mno'];
b = "Hello v1 there and v2";

output: Hello xyz there mno
Tried:
c = b.replace(/v(\d)/g,`${a[$1]}`);
c = b.replace(/v(\d)/g, a["$1"]);
But it doesn't work
a[$1] returns undefined
.replace accepts a function as 2nd argument. you should use that
||> const a = ['abc','xyz','mno']; const b = "Hello v1 there and v2"; b.replace(/v(\d)/g, (m, index) => a[index]);
@KarelG "Hello xyz there and mno" Logged: ``
@SagarV ^
Great solution. Thanks @KarelG
 
1 hour later…
10:34
hey
I'm moving some form validator functions, both sync and async into my shared module. Does it make more sense to export these validator functions from a file or expose them via a service like.. this.validatorService.validateUrl ?
I read that it should only be a service if its holding state hmm
@BrianJ you're sharing them between what? And where would the service live?
If it's frontend and backend, then I'd probably just say import both in both places. If you have a validation service that lives on the backend and you're calling it from the frontend, that nicely unifies the logic but makes the user experience worse.
I was doing this question using JS: *Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist in the array.*
/**
 * @param {number[]} nums
 * @return {number}
 */
var majorityElement = function(nums) {
    let freq = {};
    for (let num of nums) {
        if (freq[num] == undefined) {
            freq[num] = 1;
        }
        else {
    	    freq[num]++;
        }
    }
    return nums.reduce((a, b) => (freq[a] > freq[b] ? a : b));
};
Sharing them between components within the same Angular project @VLAZ. The services lives in a 'Sahred' module that exposes shared components, services etc to other components within the app.
So in that case just export the validator functions from a utils file. And import as needed in components?
So I use freq as map to count frequency of distinct element. Is this the way its written in JS? Is there shorter way to use instead of checking for undefined in freq ?
@BrianJ in that case, I'm not sure what the best way to do it in Angular. It has its own best practices and since I don't use Angular, I don't know them. I think Angular prefers you to expose services, though.
@jeea that's pretty much the solution here. If you don't like checking for undefined you can change it to:
let count = freq[num] || 0;
freq[num] = count + 1
(sorry, fixed my mistake)
10:47
hello
@VLAZ undefined || zero gives zero then
ok yeah it seems there are benefits to export functions, as they can be tree shaked
rather than a service
Yep, the || operator will return the first truthy value or if all are falsy, then the last one.
let arr = ["one", "two","three","four","five",1,2,11,3,4,5];
arr.sort(function(a,b){ return a - b })

console.log(arr)

here what is a and b mean? why not c working please let me know
it is to compare an element A towards another element B
10:50
@NIKHILCHANDRAROY a and b are simply names. The function will always be called with two parameters, you can call them whatever you like. For sorting functions a and b is a typical name, since it's just generic.
@KarelG so it is like comparator function that is in c++
It's exactly a comparator function. Don't know if C++ uses two way or three way comparison, though - some languages (or libraries) only want the comparator to return true or false, others want three values - positive, negative, and zero. JavaScript is the latter.
@VLAZ its boolean in c++ as I know
They both work. When they expect a boolean, they do something like if (compare(a, b) swap(a, b)
so, if a is greater than b then swap them. That's sort of how the algorithm works.
With positive/negative/zero the sorting algorithm can make inferences and skip some comparisons
if compare(a, c) is zero, then they are equal, thus it doesn't need to do compare(c, a). Also, if it knows that a > b, then logically c > b, as well
how can I use return a != 11 or when short 1,2,3 etc can I remove 11 one line code
10:57
you cannot sort and remove in one instruction
both are two distinct operations
1 question, why not the arrow function working here arr.sort(function(a,b)=> a - b)
why I have to use arr.sort(function(a,b){ return a - b}) why not arrow function
that's not how you use the arrow syntax
it is either function(arg1, arg2....){ ...bodyStatements...} or (arg1, arg2, ...) => { ...bodyStatements...}
the arrow syntax has some smaller constructions like
- only one argument
You can use an arrow function as well. It doesn't matter in this case. But written properly it is arr.sort((a, b) => a - b)
arg1 => ....
- arguments with one statement that returns
(arg1, arg2) => doSomething(arg1, arg2)
ect
@VLAZ thanks, it's now great looking
11:36
One thing about list in JS, is this the standard way to create list in JS
let arrayToList = function (arr) {
	let list = null;
	for (let i = arr.length-1; i >= 0; --i) {
		let elem = {value: arr[i], rest: list};
		list = elem;
	}
	return list;
};
from an array?
In eloquentjs book it is given as exercise
There are no real lists in JS, so there is no standard
Yours would work
are there pointers
Not exactly
You can have references to objects. Probably the closest to pointers you can get.
how to create a reference
a = {foo: "hello"}
b = a
11:38
actually if we pass in to function that is reference only?
That makes b the same reference as a
@VLAZ oh yes
so b.foo = "world"; console.log(a.foo) would give you "world"
Passing in objects to functions is sort of like a pass by reference.
and why are strings immutable
i mean array and object are mutable so what special purpose for making string immutable
All primitive values in JS are immutable
11:41
@FilipFilipovic 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.
hello
I'm not sure on the exact reason strings are immutable, however, it works the same way in Java. And JS was styled to look like it. I'm sure Java has a good reason for immutable strings, as well, so it might be that JS used the same reason, rather than just aping Java directly.
I think it makes strings easier to work with over all. You can garbage collect them easier, you can also safely perform many operations on them without affecting existing strings.
So, it's less complex to handle them overall.
There might be other concerns with strings I don't know about that made Java and JS choose to make them immutable.
I will explain this with a small example.
Strings (which are primitive) and arrays (which are not — they’re objects!)
have some superficial similarities.
An array is a sequence of items, and a string is a sequence of characters:

let arr = [212, 8, 506];
let str = 'hello';

You can access the first array item similarly to how you would access a string’s first character.
It almost feels like strings are arrays (but they’re not!):

console.log(arr[0]); // 212
console.log(str[0]); // "h"

You can change an array’s first item:
11:58
@FilipFilipovic thanks! really helpful .. what are other primitive value in js apart from string
when I do let i = 5; i++; then 5 does not change I mean i now holds a primitive 6 but what happens to primitive 5
I mean 5 is number primitive so it cannot change !?
12:16
@jeea Let’s look at this example again.

let pet = 'Cat';
pet = 'Dog';
console.log(pet); // "Dog"

We know that string values can’t change because they are primitive.
But the pet variable does change to "Dog". What’s up with that?
This might seem like it’s a contradiction, but it’s not.
We only said it’s the primitive values that can’t change.
We didn’t say anything about variables!
Variables are not values.
Variables point to values.
Imagine a variable as a 'wire' to a certain value in memory.
12:29
Anything exciting going on in here?
12:46
@phenomnomnominal Welcome back!
morn all o/
Been a while 😅
13:02
hello
not much excitement
Is everybody here working from home? (assuming you're working)
Yup.. 2 months already :)
one more week and it'd be 2 months for me
i have school from home if that counts
I guess, it does.
I hope you all have been eating healthy :)
13:05
Dunno about the others but I don't lead a very exciting life under normal circumstances. Over the last two months it's become even less interesting.
I'm having a eggs, bacon and beer diet since this all started :)
Now I have curves :D
Sexy.
Oh, you don't know the half of it :D
I've managed to lose about a kilo or two.
I've managed to find those kilos you've lost
13:08
@FilipFilipovic "corona-kilos"
@FilipFilipovic finders keepers
Not sure about my weigh, but I lost some strength and try to keep maintain my condition
:D
But not everything is bad.. I learned React, for the fun of it
I love Hooks
After years in Angular, I find it refreshing to not have to use classes
I've been doing yoga
It's nice
@KarelG strength determines your carry capacity. If you want to minmax, you can increase charisma and get somebody to carry stuff for you
Been gaming a lot more than normal. I have more time for it now, which is nice.
13:18
@phenomnomnominal you might have discovered some muscles you did not have been known about before
😁
I finished XCOM: Chimera Squad over the last weekend. It was pretty good.
not that I practice it myself. I am more an explosive-dude
kickboxing :D
I can touch my feet with my head now?
but yeah that's a "contact sport"
@phenomnomnominal like a dog? 🤪
13:20
Like a very sore 30 year old 😅
🦶
😥
I imagine it looks like this.
with a bit of 😭 in there too
|| backup
Backup Created
Yeah, it's the first face with tears I found.
So, maybe yours is more correct.
13:23
So what is everyone working on?
A new video call app
What is new about it?
I think it's actually good, from what I've heard.
nothing, just improved UI and features. Combines chat like discord with video calling like zoom or whatever.
v0.2a coming out very soon
Github link doesn't work for me, is it private?
13:27
Privately, I've been using the Guardian API to create a news app
just for the sake of practicing React
Redux
@phenomnomnominal github.com/oss-videochat
apparently dashboard requires login
https://open-platform.theguardian.com/documentation/
In case someone is looking for a good api with a lot of data
thanks
I'm currently in the process of breaking a ~200 file PR into some more reasonable ones 😅
13:30
fun fun
Doin' God's work :)
It's my own project so I could just merge it but I know I'd regret it one day :D
That one day being in about two weeks
How do you setup a user facing "report an issue" form with github issues? Users shouldn't have to have a github account in order to report an issue.
I believe they do have to
13:38
would it make sense to setup a seperate form that automatically creates issues on github?
I believe there are tools that directly integrate with GitHub. But I don't have experience with those.
Yeah, I'd look for something existing. The tricky part will be moderation
I haven't actually tried to manage GitHub issues, so I may not have all the information on that but from what I've seen when reporting stuff...I don't quite like it. It's OK but it's basically a forum thread where you post things. I think the maintainers can then tag threads/issues and force some to always have tags (e.g., non-maintainer will always produce bug or feature request).
I'd probably try to set up a different bug tracker and import GitHub issues there. It seems easier to manage that way.
But, again, maybe I'm missing some information from "the other side" that makes management easier.
hmm
14:30
Down from 211 files to 103, thats a small enough PR right? 😅
100!
heh
since it's your project ...
I would just merge it all
:D
It's pretty much a full rewrite for a 1.0.0
fyi, you can have multiple commits locally and push all of them as a chain in one go, leading to a nice history
that's my "saving" feature
and when I am done with a big task, I squash the commits to a single commit
Yeah I've been planning on squashing hahaha
14:47
hi
I copied a URL regex from regexpal and try to use it with new RegExp() constructor
Although I don't get it to match valid URL's as in the regexpal example
here is a jsfiddle - jsfiddle.net/2x7gqL4a
No error in the console about the regex being malformed.
And this is the regex originally - regexpal.com/104754
My question, do you need to modify this regex further to pass to RegExp constructor?
@phenomnomnominal sorry, had to star that
omg
just wow
I is good at code
@BrianJ you know you can use /<my regex/g in js as well?
the regex constructor is more useful for creating dynamic regexes with string (which might need some escaping)
also ... the purpose is to validate urls? right?
14:55
yep
hmm ok
why don't you check if the url is accessible
just fetch to it
if you get 200 then you know it's there
404 is not found
https://codepen.io/SkylerSpark/pen/zYvpWNZ

Look at that shit.
yeah that is a good way to go about it actually
FFS Js is annoying me today
I'm not sure if I wanna let the user fire off network request to any dodgy URL's though.. I know it won't open a page but could show up in logging
@phenomnomnominal I am missing the "Introduced more issues that will be discovered in a few weeks" commit
Finally get the stupid thing to render and its completely wrong
hours of work wasted
@Wietlol that's about 30 commits later
the discovery or the introduction?
15:02
both :D
Screw this...
Im done with canvas...
like how tf
How do you profile memory usage of a backend javascript microservice if you can't use chromes builtin memory app?
is that grounds for a question? all the other similar questions deal mainly with frontend development and memory profiling, but none for backend
Why do you use javascript for a backend?
Its usually a static feature tied into the frontend clientsided
@Jarede I assume you are using nodejs
of course
15:05
have you tried googling "nodejs memory profiler"?
no...
of course
Someone should just create a Node.JS room.
Its a complex tool on its own
15:23
most of us are very competent in nodejs because it's just JS
It's been tried -- SO Chats arent active enough and it always dies
@Jarede since Node.js uses V8, it has a memory profiler at its own
@SterlingArcher I assume you're excluding yourself there in "most" 😜
I believe it's also documented by Node.js themselves
hey
I found a good regex for my use case to test URL's. This works find but I need to convert it to a string. Is there a JS util to do that?
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi
15:30
@BrianJ again, you don't have to convert it to a js string.
that one you've posted is a regex object
In this case its a service that provides the pattern as a type string in typescript
but..maybe it makes more sense for it to provide a regex object
@BrianJ don't use regex is you need good url parsing
yeah I'm starting to think that like Karel mentioned to ping the url instead
and use the response code
I would just use a built in url parser
|| mdn new url
15:34
Wrap that in a try catch and your good
If you are using node, node has a good parser too
@JBis in this case I'm passing it to a FormBuilder.Validators prop
Validators.pattern(myValidatorRegex),
I'm not sure in this case you can pass URL() as a validator pattern
15:56
can you pass a function?
yep of type ValidatorFn so maybe I could use it
Raises a TypeError exception is invalid
I'd rather catch that in the validator function than error to console
duh..try..catch
I'm trying to design my code better. I have a Room class and a Participant class. Participants have a websocket associated with them. In the snippet here, the Room class adds a bunch of listeners to the participant socket. Ideally, the room wouldn't do this. The Participant should manage the socket, however many socket events need to access or change room level things that Participant class doesn't...
...have access to. How could I design this better?
(bit of code review)
16:21
@JBis something like this?
export function urlValidator(): ValidatorFn {
  return (control: AbstractControl): { [key: string]: any } | null => {
    try
    {
      const urlResult = new URL(control.value);
      return null;
    }
    catch(TypeError)
    {
      return { pattern: { value: control.value } };
    }
  };
}
hello
I make a js loop and put this in reactjs <div>
      <ul ref={ul}>
        {li.join(' ')}
      </ul>

    </div> but the result show "<li>0 </li>" actually I want to remove the double quote from li tag is there any whay to remove the double quote.
the output will be without quote <li> 0 </li>
|| mcve
If you would like assistance, please create a Minimal, Complete, and Verifiable Example
@NIKHILCHANDRAROY ^
@BrianJ I'm not sure how angular (I assume) does validation but that's the right idea.
 
1 hour later…
17:36
@phenomnomnominal for your information I'm quite competant >:(
"competant"
;)
You're not fooling anyone Sterling
17:52
it's true I'm a go/react guy now anyways
but my client is using node so i'll be back into it shortly
i need to test switching mics and the only usb microphone i have is one from a high school musical wii video game from like 07'
That is the perfect test environment
Sterling, what's your draw to Go?
It's been on my list for ages but every time I see Go code I think, wow, that doesn't look very nice at all
It's fast af
I'm ingesting huge files in seconds
faster than the 3rd party file uploader is doing
downside it's very low level, so you have to do tons of checking it's easy to write sloppy, crashy code
18:12
I see. That makes sense.
Had a conversation with Jake Archibald a while ago who argued that Dart and Go are kept alive only by money
I can see that being the case for Dart -- having worked with it myself, it's pretty mediocre -- but Go seemed to be a weird suggestion given how many people say they enjoy the language
A lot of augmented reality is built on go
||> (async () => { await Promise.reject(4); console.log("here") })()
@JBis "4" Logged: ``
weird
awaiting a rejection will throw
18:24
yes, thats what i thought, but it seems to continue on its way here
 if (blabla) {
            const stream: MediaStream = await navigator.mediaDevices.getUserMedia({foofoo});
            this.cachedStreams[type] = stream;
            return stream;
        }
wait nvm, i'm stupid
happens to the best of us
yay it works!
18:39
In the following code, findIndex is running over the array again and again and is increasing time complexity, so is it better to create an object inside the function and check whether property exist in that object rather than checking in array?
function countBy(items, groupName) {
  let counts = [];
  for (let item of items) {
    let name = groupName(item);
    let known = counts.findIndex(c => c.name == name);
    if (known == -1) {
      counts.push({name, count: 1});
    } else {
      counts[known].count++;
    }
  }
  return counts;
}
I have read that searching property in object runs in o(1)
So instead of searching in counts array, can we create a dummy obect for checking whether element exists in counts or not!?
make an object with the name as a key and value to the amount off occurrences (what the array values are now)
@JBis yeah I think that is better way
19:41
Hi guys
I am thinking to learn a javascript framework which has good job opportunities in job market
So i should go with React.js or angular js?
I'd suggest looking at which framework is being most used in your area and go from there.
@ILoveStackoverflow if you're looking to be marketable, I would suggest mastering native JS first. When you understand the underlying code, any framework is open and easily adopted.
Makes for a more desireable developer when they are proficient in the code that writes the framework
native js is different from react js?
native js is just javascript
ES6/7
i have coded in older angular js
so native js is Ecmascript?
19:48
that's still a framework, which has no translation to react or vue for example
yes
so native js is Ecmascript?
So first I should learn ecmascript?
Yes, learning a framework before you learn the language is running before walking
you can dive right into react, but i can guarantee I wouldn't hire somebody who did that. The skill differential is easily distinguished
So ecmascript is very essential to learn before i can dive in react or angular js?
also just fyi ecmascript is not javascript, technically. ECMA is a standard of scripting, whereas javascript is a language that follows those specs
19:53
I assumed that you were already experienced in vanilla js since you were asking about js frameworks @ILoveStackoverflow
but you should definitely learn the ecma standards as you learn. they're complicated and hard to read, and they come later. you'll reference them when you start to ask "why" more often than "how"
No I have no experience in vanilla js
Then take Sterlings advice and learn native js before any frameworks
Any good online website to learn native js ?
Pluralsight is bit expensive
I like pluralsight though
I have one
Practical Javascript
I always recommend this one
127.0.0.1 is pretty good
00:00 - 20:0020:00 - 23:00

« first day (3490 days earlier)      last day (1680 days later) »