« first day (3054 days earlier)      last day (2119 days later) » 
00:00 - 17:0018:00 - 00:00

00:01
@david how ....>
@ShrekOverflow unsure, we are having a debrief at 3pm today to find out
i'm quite curious
I know he was adding a new application to auth0 for some internal wiki thing they're spinning up
might have gotten confused about which client id was which
00:53
I wonder if he kiled the custom db
if you are using one
anyway am off to bed
its 1 am
Good idea, that's quite late. Goodnight!
I found housing my dudes, I'll now commence on building a gaming computer
for < 1000 GBP
nice! where are you living now then?
england?!
@david yep
London!
cool! i visited there last year!
00:55
@david if you visit again, lets grab a pint!
airbnb was pricey in london, and a very small place. what's yours like?
I will take you up on that, we didn't get to visit scotland last time and I would like to go up there at some point
but for now go to bed :P
@david double room, for the rent of a bungalow in India xD or a closet in manhattan
gnight
const foo = data.reduce((a, b) => a * b.length, 1);
guys whats the above code doing exactly? trying to understand reduce
01:23
it multiplies a bunch of array lengths together
so calling it on [[1, 2, 3], [4, 5], [6, 7, 8]] will wind up with 3 * 2 * 3, or 18.
!!>[[1, 2, 3], [4, 5], [6, 7, 8]].reduce((a, b) => a * b.length, 1);
@david 18
01:50
can that be written with a forloop or map?
odd question: If I am browsing a site (e.g. stackoverflow.com) is the contents of that website being stored in memory of computer?
It has to display it somehow
@greatTeacherOnizuka for loop sure, map not really'
for(i = 0; i < length; i++) {sum *= i}
?
is this what the above is doing?
kinda yeah
should be product not sum though
if you want to name it right
and it's not i, it's data[i].length
and you have to start off with let sum = 1
or let sum = 'body once told me'
02:03
ah ok got it
arr.forEach(element => {
        total = element.length * total
    });
@david can you also explain me this
return customerPreferences.every(preferences => {
    return preferences.some(selection => result[selection.colour - 1] === selection.style)
})
.every its some kind of test a value rihgt
every runs the function on all the items in the array, and then returns true if all of the functions returned true
I am trying to rewrite all this code in a different style to really understand what these new methods like every, reduce etc do
!!>[2, 3, 6, 8].every(n => n % 2 === 0)
@david true
@david false
some is similar to every, but it will return true if ANY of the function calls return true
!!>[1, 2, 3, 4].some(n => n === 3)
02:09
@david true
so how could the above can be rewritten if I am trying to use a forEach or similar
02:24
why do you want to use forEach?
or another loop
mainly to really understand how to rewrite that code
in a different way
Rob
Rob
@greatTeacherOnizuka Should be pretty straight forward to walk through. every should return false if any item fails the predicate, otherwise true
So... loop through the items and test the predicate on each. If one returns false, then the function should return false immediately. Then return true at the end
some is basically the opposite of that
yeah
02:38
return customerPreferences.forEach(
    preferences => {
        if (!preferences.some(selection => result[selection.colour - 1] === selection.style)) {
            return false
        }
        return true
    }
)
I am trying to decompose step by step
this doesnt seem to really work as the unit tests are failing now
If I make an invalid HTTP request, can the server still respond how it would like?
like if I make EAT request instead of a GET request?
or instead of GET / could I do / GET
will the request still go through malformed and can the server respond if it chooses to?
you probably won't get anything back as the server does net recognise that response
*request
Yes, but if I control the server, theoretically could I make it respond?
I guess it would basically be a different protocol
@greatTeacherOnizuka you need to keep a flag outside the forEach loop... it's a little weird
let result = true;
customerPreferences.forEach(
  preferences => {
    if (!preferences.some(selection => result[selection.colour - 1] === selection.style)) {
        result = false;
    }
  }
)
return result;
and to make some you would initialise result to false, remove the ! from the check, and do result = true the first time you find something that matches
these won't stop iterating early though, they still go through every item I think
02:58
oh cool
03:48
hi is anyone here?
@ima_prog 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.
04:43
Hey, I'm making a fetch request every 1-2s to check for an update, and when the tab is backgrounded in chrome, the rqeuests stop coming... until I tab back and open dev tools, then it's back to a request every 1-2s... what gives? I'm not a super web dev so if there's some better way to do this, I'm all ears. :)
 
2 hours later…
06:19
@druckermanly you should be using sockets
I can only assume the interval you set is being prioritized. I don't know if sockets alone would fix this, but nevertheless you should use sockets for realtime communication rather than occupying a "thread" with an interval.
The reason I say "thread" is:
https://www.quora.com/How-timers-and-intervals-work-in-the-single-threaded-nature-of-JavaScript
TL;DR - JS is single threaded. What I meant is that the tab itself is a thread (I assume) and the browser is pausing this. Sockets may not solve you problem, but service works might
10
Q: Can I use service worker with socket-io?

Aminadav GlickshteinI want to push notification to desktop and mobile. For that I following this article: https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web?hl=en I have two question: Can I use push notification to send notification after all tabs are closed (Chrome restart?) Can...

06:56
There's nothing "realtime" about this, it's just my laziest solution to a problem -- I've got a small device on my network that I've hacked together that reports its status as a file over HTTP, which I'm just polling (every 1-2s) for updates, and make a notification on modification. Do I really have to do more than fetch a URL for this to work in the browser on tabs that are in the background (service worker?)?
@DavidKamer - forgot to @ you
07:19
this is my jquery form validation
$('#msg_opportunities_form').validate( {
rules: {
text_message: {
required: true,
maxlength: 400
},
temrs_and_condp: {
required: true
}
},
messages: {
text_message: {
required: "Please enter Announcement Title",
maxlength: "Your Announcement Title must consist of at most 400 characters"
},
temrs_and_condp: "Please accept our terms"
},
errorElement: "em",
errorPlacement: function ( error, element ) {
// Add the `help-block` class to the error element
error.addClass( "help-block" );
temrs_and_condp is a checkbox but didn't work
help me plz
Please format your code (Ctrl+K when editing your message) or use a paste-site for it.
Also: Is your checkbox temrs_and_condp or terms_and_condp?
temrs_and_condp
$('#msg_opportunities_form').validate( {
    rules: {
        text_message: {
            required: true,
            maxlength: 400
        },
        temrs_and_condp: {
                required: true
            }
    },
    messages: {
        text_message: {
            required: "Please enter Announcement Title",
            maxlength: "Your Announcement Title must consist of at most 400 characters"
        },
        temrs_and_condp: "Please accept our terms"
    },
    errorElement: "em",
@geisterfurz007
anyone ?
07:49
@GauravGupta bit vague with what you mean with "not working"
checkbox validation is not working
@KarelG
name = temrs_and_condp
you cannot validate a checkbox tbh
it is either checked or not.
you have to check on submit if the checkbox got checked. If not, show error
yes
apparently we can check in jquery form validation weather checkbox is checked or not so just want to check mine has to be checked before going anywhere .
check this is complete question if it help
https://stackoverflow.com/questions/54861756/jquery-form-validation-not-working-on-checkbox
08:18
@GauravGupta it works normally if you remove that console.log ...
ok i'll do that
thanks
please don't rollback to version 2 ...
that is actually an answer.
why that one is working
ohh
that is a no-no on SO.
that is why I rollbacked to the initial version
just rollback to your
but same code not working in my site code
08:27
did you really remove that console.log there?
(maybe hard refresh the page since the result might be cached)
already done that
just now try same in private window but same old result
I can only say that the SO example you have posted functions correctly when removing the console.log entry
why? seems that $(this).find(':input') caused an error within jquery itself
it's same code just in lavarel
with csrf token
i'll be back in 30 min so plz can we continue this later too thanks
09:13
anyone there
help me plz
09:41
does the script not function correctly?
hi Ben!
it's a css error designer did display none to my input field in css file which cause problem
working fine now thanks @KarelG
aha. the problem was somewhere else
yep hard to locate too
10:55
Hi guys! Can you tell me what is this for a date format string and how can I convert it to yyyy-mm-dd? Object in JS: Date: "/Date(1551049200000)/"
Never seen this before.. d'oh
that's a timestamp in ms
Morning. Sorry to ask this really stupid question, but I'm on my own in the office & don't have much angular experience. How can I work out where $rootScope is being defined so I can add something?
user8444404
11:28
2
Q: Shadow/Flash displaying when dragging image

vickey colorsWhen user upload image and when he try to drag the image , the image will display flash / shadow along with dragging, but i don't want to display the shadow.... codepen : https://codepen.io/kidsdial/pen/xMNbVz $(document).ready(function () { // dont have a webserver so ...

12:01
Hi All
got a clarification in ES6?
@CommonMan No clarifications in sight.
!!welcome CommonMan
@CommonMan 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.
Is global variables can be declared in ES6 javascript?
(An interviewer argued with me that there is no global variable can be declared in ES6 js)
just do <script>var loco = 'here is my global variable';</script> ?
54
A: JavaScript and ES6, "global" variables

MacmeeYou can always assign variables to window.MyClass = whatever (global.MyClass for nodejs) no matter where you are, and access these values from any other file in your application. That's not always the best way to go about sharing data globally in your application though. The module loader in node...

12:06
@CommonMan I know what he's talking about.
And he's wrong, strictly speaking.
Global variables are possible with ES6.
He sounded more a bookworm to me...
grabs popcorn Another session of JS weirdness with Madara \o/
What he's referring to is the fact that modules are always in strict mode.
The "kind" of global variables they're thinking of is something like this:
function foo() {
  x = 5; // x is global now. Note that I didn't use const or let or var.
}

foo();
console.log(x); // 5, even though we're outside of foo()
This code, in a <script> tag, works even in modern browsers today that support 100% of the ES2015 specs.
However, inside of a module (files using the import and export keywords, or files bundled by webpack and transpiled by Babel/TypeScript) that code fails.
Because that code fails in strict mode
However, even in strict mode, you can still do function foo() { window.x = 5; } and it would still work.
So to the question of "can global variables be declared in ES6" -- the answer is yes.
window.x = 5; can be a global variable? @MadaraUchiha
@CommonMan In browsers, window is the global object. (global in Node.js)
Anything you can access globally is found on the global object.
Even things like the Math object.
(If you want to see for yourself, open your devtools console and type window.Math === Math and see that you get true)
12:12
so obviously in ES6 it should work in the global scope and can over write it in strict mode as well
Here's an example from node
In browsers you'd use window instead of global.
That works even inside of ES2015 modules./
and... here goes another answer from me and I urge this great genius community to prompt if my answer to the interviewer was wrong or not....


he asked me what is a closure? I told, a variable possessing a function... with a return value can be called as a closure...

He disagreed and told a function within a function is a closure...
It's worth noting that this is all an "academic" discussion. You should almost never use global variables in code. At all.
@CommonMan He is closer than you.
so my answer was close for the global variable question?
wrong?
Normally, when a function returns, its scope ends and all the variables defined in it are gone, and eventually garbage collected.
function add() {
  const a = 5;
  const b = 6;
  return a + b;
}

const c = add();
// add is called, a and b are allocated, add returns, a and b die.
But, in JavaScript, I can return functions from other functions.
function makeAdd() {
  const a = 5;
  const b = 6;
  return function() { return a + b; };
}

const add = makeAdd(); // add is a *function*, not a number.

const c = add(); // 11
Now, makeAdd() returned in line 7 of that example. So a and b should have died
But since the returned function (assigned to add) references those variables, they are kept alive.
This is called a closure, because the function has access to the enclosing scope, in which it was defined.
A "closure" is the act of an inner function capturing or "closing over" variables from an outside scope, even after that scope had normally ended.
@CommonMan If you argued that global variables are possible, and he argued that they were not, then you were right, and he was wrong.
12:20
@MadaraUchiha - Thank you so much!
I will have to read your answer on the closures... and have to understand before that could you declare your verdict that if my answer was correct or not.
@geisterfurz007 Wasn't that weird, was it? :D
@CommonMan developer.mozilla.org/en-US/docs/Web/JavaScript/Closures Some more good reading material.
It wasn't actually! Stuff that I (somewhat) knew but could have never explained that well :)
I feel cool now because my tests are green c:
Hey folks
How do I test a faulty connection? I'm getting interminnent issues
with the monitor display flicker
I thought it was the displayport connection, but it seems like that wasn't the case
however, swapping the displayport cable did reduce the amount of flickers
any idea 😛
Have you tried turning it off and on again?
12:35
any "web" portal to force monitors with high amount of data to cause them to flicker?
@geisterfurz007 a few 100 times
user8444404
how to add shapes like these : prnt.sc/mptq2q ?
Draw them
or check out font-awesome
@vickeycolors mspaint
@ShrekOverflow You mean a website that changes quickly? Would a canvas be enough? There are websites/videos that claim to fix monitor issues by rapidly turning on and off colors trying to get contact on the LEDs.
yeah that is what i was thinking
user8444404
12:37
Thanks @ShrekOverflow & @MadaraUchiha
That is usually for individual LEDs that are broken but maybe it's what you want.
youtube.com/watch?v=_t7qt_fRlgU WARNING! STRONG FLASHING LIGHTS!
> This fixed my issue perfectly! Now I can't see the monitor at all so there is nothing to worry about!
@geisterfurz007 I don't think you mean LEDs. Flashing a monitor won't affect the LEDs
I mean pixels then ._.
 
2 hours later…
14:13
Why is the following invalid? "calc(100vw - (100vw - 100%)) * 2"
the *2 is outside the calc
The multiply symbol seems to be the problem
Sam
Sam
How can I pull out all ID's from JSON data and store them in a vector? Data looking like this:
wrap your current calculation in braces, and multiply that by 2
Sam
Sam
0: {Flavour ID: 1, Flavour name: "menthol"}
1: {Flavour ID: 2, Flavour name: "sam"}
2: {Flavour ID: 3, Flavour name: "sdsds"}
3: {Flavour ID: 4, Flavour name: "Strawberry"}
4: {Flavour ID: 5, Flavour name: "Cherry"}
5: {Flavour ID: 6, Flavour name: "Grape"}
14:15
Thanks @towc
Sam
Sam
Suppose I want to put all IDs into a vector?
@Sam That's not valid JSON, and JavaScript has no concept of vectors.
@Sam firstly, your data is not quite json
Be more accurate.
[{"Flavour ID": 1, "Flavour name": "menthol"},
{"Flavour ID": 2, "Flavour name": "sam"}, ...]
14:16
@towc That's not valid JSON either, nor valid JavaScript, for that matter.
this would be valid json
@MadaraUchiha hold your horses
@towc That it would. But it isn't clear to me that this is what he's got in his hands.
That looks like a paste from the devtools, which implies that they don't have JSON at all, but a JavaScript object.
yeah, creating an example so he can compare
@MadaraUchiha oh, good point
Sam
Sam
Sorry, my above paste is just the output of a variable in devtools. Its a JS object
^yeh, sorry
Is it an array?
14:18
@Sam ok, so now already have an array. Look up array.map
arrays are what you might call a vector in c++/rust
Sam
Sam
OK. To me vectors are just 1D arrays but yeh it makes sense to be consistent with the language. :)
@Sam arrays and vectors are generally different things, regardless of dimensions 😛 C++/Rust/Java 1d arrays are different from C++/Rust/Java vectors
Ok.... This is some JavaScript rubbish, I don't understand again... I got the following code snippet as part of a Jest test for a React Native component:
image.props.selectable = true;
console.log("This should be true: ", image.props.selectable);
Now... That thing is false. And I am strongly confused...
image is created with the react-test-renderer. Does that lock the values somehow?
Or are props immutable in general?
14:25
well, you shouldn't mutate props like that, probably, anyway
I don't know if it allows you to or not
the general pattern is that props are objects
and then you can mutate those object's properties
or functions, and then you can call those functions
Ok so if I were to image.props.getOwnPropertyDescriptor().configurable I would know if I can change those or what?
@geisterfurz007 I guess
also, note that it's a static method on Object
Object.getOwnPropertyDescriptor(image, 'props').writable
Oh! Yeah lemme try that; one second
configurable is for allowing you to change the descriptor, which you almost never want to do anyway
Configurable { value: false,
      writable: false,
      enumerable: true,
      configurable: false }
14:28
well, there you have it, it's not writable
oh and woops, that should be (image.props, 'selectable')
Fancy stuff, thanks for the hint! Yeah, I used that :)
I'm sorry if you can't handle all the tophats in this room
Makes more stuff anyway... One test for trying to select the image when it's not selectable and one for trying to select it when it is selectable...
huh, I'd have figured that js would throw when writing to a non-writable:
> Object.getOwnPropertyDescriptor(window, 'closed').writable
false
> window.closed = 1
1
> window.closed
false
funnily enough, it does on frozen objects:
1 message moved to Trash can
@SebastianNielsen Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
14:34
> Object.assign(Object.freeze({}), { x: 1 })
VM1333:1 Uncaught TypeError: Cannot add property x, object is not extensible
> // but
> Object.freeze({}).x = 1
1
> // object still unchanged
well
good news is Object.assign respects writability too
Honkers, ponkers, tests go green!
> Object.assign(window, { closed: true })
VM1463:1 Uncaught TypeError: Cannot assign to read only property 'closed' of object '#<Window>'
Thanks towc :)
TIL :D
anytime. Almost.
14:48
huh, this is a fun one that I'm sure @MadaraUchiha can torment interviewees with: what's returned by Object.getOwnPropertyDescriptor(window)? non-spoiler hint: a25vd2luZyB0aGF0IGdPUEQoe30pIGlzIGB1bmRlZmluZWRg
I wonder if this works in non-chromium browsers
!!> Object.getOwnPropertyDescriptor(window)
@ShrekOverflow "ReferenceError: window is not defined"
@ShrekOverflow why would you ruin it anyway
!!> Object.getOwnPropertyDescriptor(global)
14:49
plz !!undo and delete
what's wrong with you
@ShrekOverflow I have no idea what happened:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" href="https://cdn-chat.sstatic.net/chat/css/chat.meta.stackexchange.com.css?v=8f4a5480c18d">
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackexchangemeta/img/favicon.ico?v=cc">
<link rel="apple-touch-icon" href="https://cdn.sstatic.net/Sites/stackexchangemeta/img/apple-touch-icon.png?v=cc">
<link rel="search" type="application/opensearchdescription+xml" title="Chat for chat.meta.stackexchange.com" hre
great
:clap:
👏🏻
👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻👏🏻‌​👏🏻
!!clap you have both had more than enough time to learn how the bot works
14:51
you 👏 have 👏 both 👏 had 👏 more 👏 than 👏 enough 👏 time 👏 to 👏 learn 👏 how 👏 the 👏 bot 👏 works
you can move to bin, right?
undo should have worked lol
you broke her
and I keep forgetting lemon
@GNi33 :(
but why should you bin it anyways?
14:53
@GNi33 it's a spoiler
Spoiling who?
oh my
ugh, fine
I mean, it's ok, I'm just confused
14:54
1 message moved to Trash can
pro tip: don't ask questions like this in an interview
with that hint, it's actually quite reasonable
but before giving that hint, you can get a feel of what someone would say if they have no clue how js behaves in that scenario, which I think is the majority of us
@GNi33 or do, but no one will want to work with you or the candidates this pulls in.
> a25vd2luZyB0aGF0IGdPUEQoe30pIGlzIGB1bmRlZmluZWRg
this hint?
14:56
yes
I don't know what to say
what did you think was going to happen?
and even after giving the hint, there's some more internals to think about
still, not something you are probably ever going to run into in production, but I don't think most of madara's questions are
at least, the ones he shares here
well, if you think giving base64 encoded hints is a fun thing to do in an interview...
@GNi33 oh no, the hint is for the room
which would be given by the interviewer at a later date
> here is the answer in md5, your task is to write the lookup table to crack it.
14:59
haha, I was really confused at first
it feels like it maybe should be part of the original question
still, my answer would be "give me a browser with a console and I'll tell you"
@GNi33 well, questions on this are still valid questions
and you're probably asked not to run the exercises for them
15:24
why'd you delete the question
15:37
posted on February 25, 2019 by CommitStrip

lol @ alt text
15:56
!!clap b- caprica
b- 👏 caprica
😎
!!clap 👏 👏 👏 👏 👏
👏 👏 👏 👏 👏 👏 👏 👏 👏
Hey guys can anyone help me understand whats happening with this code and how can I rewrite it in a different style? possibly without using array.from , every and object.assign
    const colors = Array.from({ length: numColors }, i => null)
    const found = candidate.every(preference => {
        // if trying to override a readOnly color (or using a readOnly color to override)
        // the solution is not valid
        if (
            colors[preference.colour - 1] &&
            (colors[preference.colour - 1].singleColour || preference.singleColour) &&
            colors[preference.colour - 1].style !== preference.style
        ) {
            return false // stop iteration
16:03
@greatTeacherOnizuka a simple step is to read the documentation of those functions. Each MDN documentation describes what those functions does and provides a polyfill section (if applicable)
So I have a strange issue with embedding a cloudflare video, if I write markup in html it works but if I create the markup with javascript nothing happens.
https://developers.cloudflare.com/stream/recipes/javascript-api/

I tried a lot of things already, including firing the window onload again manually, using a MutationObserver etc. but to no avail.
What else could be the problem?

No error messages in the console, just nothing happening
I was unable to find an unminified version of r4xu.fla9.latest.js to check what it is doing ... :-/
@MarcelBurkhard show what you've got and what you've tried. describing it is nice and all, but you maybe have mistakes there.
the fact that there is no error message, and it doesn't work dynamically, is probably a dom loading issue
Alright I'll have to isolate it, I'll post back
Ok well it works in isolation
I don't get it
On the "real" thing it's in a polymer component, but the elements are added to the shadow-root, yet the video doesn't show up
16:35
well considering that your 'stand alone' example works fine. investigate the polymer stuff
isolation doesn't benefit you unless you can isolate the problem.
right now you haven't done that yet.
yeah I'm working on that
thx
@MadaraUchiha nobody, but im really struggling to format a DateTime into a javascript getTime() using moment
0
Q: Issues to formatting a stdin to string (removing \n character)

greatTeacherOnizukaI wrote a function that breaks a string when it encounters the newline char and joins all the rest of characters together. E.G. from an input that looks like 2\n1 P 3 B 5 P\n2 P 3 B 4 B\n5 P I would end up with an array that looks like: [ '2', '1P3B5P', '2P3B4B', '5P' ] This works great wh...

anyone?
00:00 - 17:0018:00 - 00:00

« first day (3054 days earlier)      last day (2119 days later) »