« first day (3331 days earlier)      last day (1842 days later) » 

04:04
@Wietlol is that offer still available? I was too lazy to read through all that.
Hi,
interface IObj {
    fname: string;
    lname: string;
}

const obj: IObj = <IObj>{};

const array: string[] = ['fname', 'lname'];

array.forEach((key: string, index: number) => {
    obj[key] = `${index}`;
});
@Shubham Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. 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
@Shubham Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. 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
Hi,

interface IObj {
    fname: string;
    lname: string;
}

const obj: IObj = <IObj>{};

const array: string[] = ['fname', 'lname'];

array.forEach((key: string, index: number) => {
    obj[key] = `${index}`; // Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'IObj'.
});


How can I resolve this issue in typescript
@Shubham sorry to be a little mean, but you cant just post code and expect us to know whats wrong without explaining it and just pop out an answer
@TaylorS I've added the error as comment. I'm not able to access keys dynamically in obj.
04:19
hmm
well, considering your referencing the obj constant
which is referencing IObj
I think itd be more efficient to just use
    IObj.fname = '${index}';

instead of

   obj[key] = '${index}';
I find it hard to to see why your referencing a duplicate reference
thats like doing:
var a = 1;

var b = a;

var referenceVar = b;
@TaylorS That I understand. But I have a large number of keys in my object and I want to access it dynamically using an array.
but setting a second const isnt going to change that
IObj is already an array
setting it to an array with a const string array statement wont do anything? (and may well be causing your problem)
@IObj is an object.
looks like a custom object
interface <name> {

}
if that is based on javascript, you should be able to scope it just like any normal array
is it from a library? if so, I dont think they've written proper support for arrays.
but from what I can tell:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'IObj'.
I believe that it doesnt support converting "object interface" into "object string array" and into "array"
I've always stayed away from libraries that enforce custom objects
always causes trouble, except Dat.GUI
(Oh sorry just searched, thats not a library feature, sorry i never use typescript)
@TaylorS thanks anyway.
04:29
Oh wait
Just found a similar issue
may have your solution
164
A: How can I define an interface for an array of objects with Typescript?

basaratYou don't need to use an indexer (since it a bit less typesafe). You have two options : interface EnumServiceItem { id: number; label: string; key: any } interface EnumServiceItems extends Array<EnumServiceItem>{} // Option A var result: EnumServiceItem[] = [ { id: 0, label: 'CId', ...

Check out the answer
04:42
const array: (keyof IObj)[] = ['fname', 'lname'];

array.forEach((key: keyof IObj, index: number) => {
    obj[key] = `${index}`;
});
Found the answer
04:54
nice.
Hi All,
this is not a javascript question, but some fundemental question about how to explore more as a developer.
Im learning about nodejs and gone over event loop tutorials. I have theoretically understood how and event loop works. But how do i go over in depth with my application
code for understanding the same.
Over the years, what have been my concern is, im have managed to be a average programmer, who understands the existing code or can google / find a approach to fix something.
Any suggestions / techniques in terms of how i can go in depth of everything on a architechture front woul
(see full text)
If you wanna go full front end, take IT School or courses
Or just read Language Documentation like 20 thousand times over
05:45
@SamSam So you are trying to learn more about how JS work? I would read articles regarding the event loop and the v8 engine. You can also look at the source code as it is open source. Low level tends to get extremely complicated. Good luck :)
 
2 hours later…
07:24
Things I hate about wool sweaters: they don't have a chill period. They're always working overtime to keep you warm, but also to make you hot if you're already at room temperature
</soapbox>
That's why I just wear T-Shirts (and also because I am too lazy to iron my shirts ._.)
I would tend to do that too, if anything wear cotton sweatshirt on top, because at least those breath
but when it gets really cold out, the wool sweater works wonders. The problem is always when you're not outside
Just... take the wool sweater off?
so now I'm wearing something that I have to put on and take off all day
no, that's what jackets are for
So wear a wool jacket!
07:31
they don't make them :(
(And they would be a mess in rain :D)
though probably there are woolen linings for jackets
08:11
I just go with a polo to my work
I have a good jacket for the cold weather outside
that I even don't need a sweater
yeah, but you're probably used to cold weather
they also probably heat buildings well there. Here, it depends on who's paying..
me, used to cold weather?
nah, give me 30 degrees C
i'm not a polar bear
@geisterfurz007Stopthischaos sure, I currently have it running already tho :D
but it uses eval(code)
Ok so you don't need it anymore?
if you can change that so it supports more, then go ahead
08:21
That doesn't get you the output tho
well... I think async doesnt work... not that there is anything you want to do asynchronously
oh ye, I simply reassign console log
literally
console.log = (obj) => items.push(obj)
or something like that
dont really recall
but you can break it now
You can also do what JBis did in his bot and add something like console.error = console.debug = console.warn = console.log after that to get all output.
geisterfurz, any chance to update your name?
was it not temporary? no?
and there's a long name now when you got pinged
08:25
I guess there is, yes.
08:49
Hi ! :)
@oskll 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.
09:18
@oskll hi! sorry, didn't see your message with all these chatroom messages happening
as you can see, this chatroom is thriving! (¬_¬)
ohai niel, you wanna join in some fun?
geis and I are trying to break wietbot :D
I am still waiting for @MadaraUchiha to join too
09:35
I don't really think that it's breakable. Relying on an external sandbox provider that itself uses on resetable containers without internet access and a read-only filesystem leaves very little attack surface.
that is the idea
all eval features rely on that security layer
it would be sad if I have to fix something (say file access) in all of them in the code
then I would have to figure out how to prevent that for
node.js eval
csharp codeanalysis scripting
javax.scripting nashorn + kotlin
groovy groovyshell
and this list could grow
say... Wietlang?
so, yes, I really hope we cant break it in its current state
09:56
I have some questions, I have an idea of a mobile game, not very complexe, with user inputs and some animations maybe and I wonder what will be the best way to create it ? I saw that there is react native game engine now or maybe I should go with Unity directly ? :)
Unity is better in that regard and it allows you to develop pc games if you have interest in developing an "indie" game as well
but inform yourself first with what you can do with Unity and see if you actually need it.
if you are creating a simple card game, then using Unity is an overkill
Thank you, yeah I think Unity might be overkill for what I want to do that's why I'm asking
you have to compare usable libraries and pick which one suits your project requirements
10:16
@KarelG we wrote our game backend in Node
(MY SO is indieing a release for the heck of learning it)
as a result the UI Layer can be literally anything -- It's a card game
We prototyped with SwiftUI / React on Web
The learnings were fun though
10:29
Thank you :)
11:02
going to start by saying i know practically nothing about javascript, i am trying to call a javascript function on load of my view in ASP.NET, my view is a chart and i am trying to call the function that creates the chart, i have tried using the window.onload but it just puts that as text onto the view, have i put it in the right place? prntscr.com/q3scxi
<body>
    <div id="chart_container">
        <canvas id="bar_chart"></canvas>
        window.onload = function() {
        barChart();
        };
    </div>
</body>
11:13
@WhatsThePoint the browser has interpret it as plain text, not as a JavaScript code
to tell them that it is a JavaScript code, you have to wrap it in <script> tag
eg
<div id="chart_container">
    <canvas id="bar_chart"></canvas>
    <script>
    window.onload = function() {
      barChart();
    };
   </script>
</div>
@KarelG Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
and I would suggest to use a different load handler
what would you suggest?
document.addEventListener('DOMContentLoaded', function(){
  barChart();
});
with this, the browser is executing barChart() while the browser is still busy to get images/styles/iframe sources ect which can take time. Just to have a fully functional page slightly faster :P
its literally the only thing on the page
and thank you for the information
11:32
could someone tell me why the one('click' is not working? jsfiddle.net/y6L1uk23
@oskll The point is it depends
Seperate the Game UI / UX w/ Core logic
@boss you probably meant .on(... ?
(remove the "e")
i removed and it did not worked: jsfiddle.net/rbgpkny5
aha
you are doing $('.click_btn').on first while there is no elements with that class name
it is only a part of the document when you focus that input box
the .click_btn is inside the $('input').on('focus', take a look
11:47
but the newly created button that you have added to the document does not have any event listeners on it (set via .on(...)) so nothing "happens" if you click it
you have to set the click listener after it is added to the DOM
you need to manage the stuff better tho. those events with focus/blur and adding/removing a subelement is just eww
if you try to click the button, the blur event gets fired, removing the element that you want to click on ect ect
i know that it's not working because of the blur event. but as you can see: jsfiddle.net/k6gjrv8b/1 i removed the code that removes the button on blur, and the button still don't trigger the click event
only after the .sub_div is removed, so i need to click it twice to trigger the click event
ok, i will use another event to remove this red div
12:21
it is better to not rally events
unpredictable :P
12:44
@ShrekOverflow thank you for the precisions ! :)
I'll look into that
 
1 hour later…
14:08
Hello everyone I have question this is interesting for me when I write script in my package.json file for prettier if I use backspace for path this is work normally but when I not use backspace this is search folder in node_modules folder why?
Hi Everyone, What is the best to populate html Elements in a clean way from JSON API in .net core? I want to use Jquery
@muhammadtayyab 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.
14:29
@MuradSofiyev package.json contains node packages usually, so I think it is correct behavior
15:10
Why Chrome supports NFC and Bluetooth now but doesn't have to write 1 callback to their browser that would improve the UX massively for the user across the board is beyond me.
15:22
@MuradSofiyev backslash escapes characters
that's why generally forward slash is preferred for paths
15:43
Fuck chrome seriously
I mean it makes 0 sense why the Chrome team wouldn't add 1 callback :|
Maybe Chrome is listening
Let's decompile Chrome build and add that callback and present it to Chrome team and let's see what surprise will come out :D
@muhammadtayyab De compile? Dude you can literally see the whole source code on their repo
@muhammadtayyab to Google Business needs, yes.
@ShrekOverflow then you have a good solution for Chrome, you can try it out for good
15:50
@muhammadtayyab I don't think you understand the problem
Probably, what's this 1 callback by the way
func applicationDidFinishLaunching(_ aNotification: Notification) {
    let manager = ASWebAuthenticationSessionWebBrowserSessionManager.shared
    manager.sessionHandler = MyAuthenticationHandler()

    if manager.wasLaunchedByAuthenticationServices == true {
        // Adjust startup behavior accordingly. In this case just open a window
    }
}
@ShrekOverflow Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
Its basically developer.apple.com/documentation/authenticationservices/… if they were to add this, their own native apps (like Google Drive) would allow the user to login via Google Chrome and re-use the existing session.
15:58
They already have applicationDidFinishLaunching anyway
if they do this, MSFT miht also consider this and then
then for once we will have a reasonable way to login to desktop
I mean windows has docs.microsoft.com/en-us/uwp/api/… but its bound to a really weird system browser not even Edge or IE
also in browsers that claim being about users and not implement it, Firefox!
 
2 hours later…
18:21
Hmm Single sign-in and have liberty of native app like progressive apps
18:46
 
2 hours later…
20:57
anyone alive?
looks like a ded room :(
need some feedback on js code
like...
function stringify(object) {
    if (object === undefined)
        return "undefined";
    if (object === null)
        return "null";

    const toString = object.toString();

    if (toString !== "[Object object]")
        return toString;

    return JSON.stringify(object);
}
Produces weird results for stringify("[Object object]")
stringify("[Object object]") // => "\"[Object object]\""
Where the expected result is "[Object object]"
good catch
function stringify(object) {
    if (object === undefined)
        return "undefined";
    if (object === null)
        return "null";
    if (object === "[Object object]")
        return "[Object object]";

    const toString = object.toString();

    if (toString !== "[Object object]")
        return toString;

    return JSON.stringify(object);
}
I'd probably go with
function stringify(object) {
    if (object === undefined)
        return "undefined";
    if (object === null)
         return "undefined";
    if (object.toString == Object.prototype.toString)
      return JSON.stringify(object);

    return object.toString()
}
what if object is null?
Fixed :p
21:04
i see
better yet, maybe this:
better what?
function stringify(object) {
    if (object === undefined)
        return "undefined";
    if (!object || object.toString == Object.prototype.toString)
      return JSON.stringify(object);

    return object.toString()
}
Maybe that's less obvious
I'm trying to capitalize on the fact that null is safe to pass to JSON.stringify
The only actual edge cases you need are undefined, when the object doesn't have a toString method, and when toString is Object.prototype.toString
Unfortunately you can't just ask "toString" in object because that also blows up for null
So maybe it's just clearer to treat null like a special case as well
ye, ill keep it as it is now
 
1 hour later…
22:19
hey everyone,
QQ what is the purpose and or opinion about using an object as a type vs just using an interface as a type. I get one creates an object and what is just a virtual representation but what is the actual recommendation.
I found this really good article here. oh by the way this is referring to type script.
what the article leaves me questioning are the real life implications of using one vs the other. I will give a myworld example.
public getTop(result) {
           Let top = xxxxxxxxxxx.top;
            return top
        }
i was using this. and thought to myself I am going to need to recreate an object that is sent over instead of just top
so I went to create and object and though hmmm. do I want an interface an object or a class reference for said object.
an interface would have looked like this.
export interface TopThing {
        public top: string;
        public score?: number;
}
the class looks like this.
export class TopThing {
    constructor(
        public top: string,
        public score?: number
    ) {}
}
22:40
when i change json file and refresh page i dont see changes (nodejs)

Its not that important im just curious why. Client will change stuff from User interface anyway and not directly from json file.
Does anyone know why it wont update the page after i refresh? It should fetch the json file and render the data.
next to me in that moment would be the decision of what to choose to do next. if I chose the interface then I would have to build my object to pass along at that moment
I read it with fs.readFileSync and render it, it should do it on each refresh no..
for an interface this is what I would have created
 public getTop(result) {
            const topThing: ToptingI = {
		top: xxxxx.top,
		score: xxxxx.score
	    }
            return topThing;
        }
lol but then that is when i read the article and said wait why am I making this descions what is the correct and or better way
also, what I noticed is that doing an "on the fly object" is only good for that moment for that function. No place else
and that is when I had an ah ha moment. interfacing doesn't really address the reusability of calling a or creating a new object all of the time.
in this way interfacing is simply a type checker AND it doesn't get to be passed along when you return the function*** this is huge
so then i implemented this per the article
 public async getTop(result) {
            const top = xxxxxxx.top;
            const score = xxxxxxxx.score
            return await new TopThing(top, score);
        }
here, everything is happening at once. A new object is created. The function is now typed and it is passed through to the method calling it. And it is an object that can be used or implemented in other places easily.
is this a much better way to do this than every using interfaces? Or if it is REALLY ONE OFF then I guess an interface would be fine? But then what's the point of it?
just wanted extra opinions of this?

« first day (3331 days earlier)      last day (1842 days later) »