« first day (3167 days earlier)      last day (2004 days later) » 
00:00 - 19:0019:00 - 00:00

00:18
Adobe at it again with very cool tech youtu.be/TUootD36Xm0
 
2 hours later…
02:37
0
Q: Why can't I assign `push` function to a variable?

JBisHere's my first example which works as expected: const testObj = { func: (str)=> { console.log(str) } } const testVar = testObj.func; testVar("Working"); //logs "Working" However if I try the same thing with a push function, it is undefined. const array = []; const t...

03:17
Can someone please help explain why this function is not counting vowels?

I'm trying to use recursion to count the number of vowels that occur in a string:
function countVowels (string) {
  let count = 0;
  if (string.length === 1) {
    if (string.match(/[aeiou]/i)) {
      count ++;
    }
  }
  else {
    let lastChar = string[string.length -1];
    console.log(lastChar);
    if (lastChar.match(/[aeiou]/i)) {
      count ++;
    }
    countVowels(string.slice(0, -1));
  }
  return count;
}

console.log(countVowels("helloWorld"));
I'm getting the lastChar correctly....and am trying to cut the string down by 1 char each time using recursion....it was my understanding that string.slice(0, -1); was the way to remove the last char from a string....maybe this is closer:
function countVowels (string) {
  let count = 0;
  if (string.length === 0) {
    return 0;
  }
  else {
    let lastChar = string[string.length -1];
    if (lastChar.match(/[aeiou]/i)) {
      count ++;
    }
    countVowels(string = string.slice(0, -1));
  }
  return count;
}

console.log(countVowels("helloWorld"));
But still returns 0
@HappyHands31 Why use recursion?
Being forced against my will 🔫
Teacher?
Right lol
ew. Alright well lets take a look
03:34
I guess you could also take away the first char. This works:
function countVowels(string) {
  if (string.length === 0) {
    return 0;
  }

  let numVowels = 0;

  if (isAVowel(string[0])) {
    numVowels += 1;
  }

  numVowels += countVowels(string.slice(1))

  return numVowels;
}
When your using recursion like this, you don't want to have a "global" variable like that count
Okay
Sry here, this works:
function countVowels(string) {
  if (string.length === 0) {
    return 0;
  }

  let numVowels = 0;

  if ((string[0].match(/[aAeEiIoOuU]/))) {
    numVowels += 1;
  }

  numVowels += countVowels(string.slice(1))
  return numVowels;
}
function countVowels(string) {
    if (string.length === 1) {
        if (string.match(/[aeiou]/i)) {
            return 1;
        }
        return 0;
    } else {
        let lastChar = string[string.length - 1];
        if (lastChar.match(/[aeiou]/i)) {
            return 1 + countVowels(string.slice(0, -1));
        }
        return 0 + countVowels(string.slice(0, -1));
    }
}

console.log(countVowels("helloWorld"));
or you could do first letter as you said
you could also convert to an array and use shift()
@HappyHands31 May I ask what year of schooling you are in where they are requiring you to do it this way?
If you didn't need recursion you could do:
function countVowels(string) {
    return Array.from(string).filter(char => char.match(/[aeiou]/i)).length;
}
TY - Fullstack Academy coding bootcamp in Chicago
Interesting so you have
      return 0 + countVowels(string.slice(0, -1));
Where I just had
03:50
The 0 is unnecessary but it is a bit more clear what's going on
countVowels(string = string.slice(0, -1));
Yeah that helps clarify. Thanks.
 
4 hours later…
user6718998
07:28
Hi. Anyone can help with event emitters ?
07:39
!!welcome thewise
@thewise 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.
08:00
Hi, anyone could look at my question stackoverflow.com/questions/56639517/… ?
thank you so much to whoever voted
@Dwigh please don't request for up/down votes. Only close-votes can be requested (by )
ok..
im done
@Dwigh can you say why you wanted an upvote/downvote now?
no. sorry. im doing anything against sO rules or anything though @neil
@Dwigh oh ok, well it was just my curiosity
var emails = [];
emails[] = [['Name'],['Amount'],['Date'],['Email']];
why getting an error on this?
You've been using too much PHP
javascript
a syntax error
08:19
You can't do that in JavaScript
You need to use push/concat etc
ok.. thanks
anyone knows google apps script?
I want to add button in the menu of google spreadsheet and make functionality on it..
08:40
@Exception seems like a fairly straightforward thing
you can't find anything online?
nope that is the problem. can you help
You mean as part of their UI?
Not sure you can do that
15
Q: Adding Buttons To Google Sheets and Set value to Cells on clicking

PrasadI am new to Google Script. I have a Google Sheet with 5 columns, on each column I need a button (with text 1,2,3,4,5). And on each button click I need to set text of button to corresponding cell and hide the clicked button. Is it possible?

Oh, turns out you can
08:42
would be a good place to start
thanks for that link but problem statement is that I need to add button in the menu which once clicked will be deactivate for 2 days and text over that button will be changed for that 2 days itself and then after 2 days the original button name will be displayed
hmm, to make that work, you'd need to run script when the spreadsheet is loaded
and you'd also have to be able to set a cell value
Yes
that will be dynamic as per requirement
but if you can do these things, it's possible. You'd have to save the current timestamp in a cell, and when the spreadsheet is loaded, check the timestamp saved
if more than 2 days have past, then you reactivate (and change menu text)
otherwise you leave it disabled
08:45
you are absolutely correct..
next click, you update the timestamp
You might be able to use developers.google.com/apps-script/reference/cache to store a timestamp
I'm not sure how long it persists though
But first problem is "add button in menu"
Or another hack would be to store a timestamp in a readonly cell and use that to determine when to show the menu
08:47
@Exception That's the easiest part.
yeah it would be better if you could use the cache, but otherwise, you could just place it in a readonly cell
preferably hidden from view
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addSeparator()
      .addSubMenu(ui.createMenu('Sub-menu')
          .addItem('Second item', 'menuItem2'))
      .addToUi();
}
Apparently this will add a custom menu on load
so that part's done
I'm intrigued, give me 5 minutes
but that is not reflecting in the spreadsheet..
my apologies.. its displaying
08:51
@Exception what do you mean?
sorry
function menuItem1() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
     .alert('You clicked the first menu item!');
}
this is what gets executed when you click on "menuItem1"
Anyone knows the best source of all es6 shims and polyfills?
So add in the logic of what you want to have happen when clicked here
Done..
thanks for that..
next is about time for 3 days activate and deactivate
09:02
I don't think you can use Cache, since it seems to suggest it won't necessarily retain the information after a period of time
@Exception Is the "deactivation" per user or per spreadsheet?
@BenFortune hah, I was looking at the very same
I think it will be independent of user
then you should use PropertiesService.getUserProperties();
PropertiesService.getUserProperties().setProperty('lastClick', date);
date should be a string representing the time of the last click
when spreadsheet is loaded, do PropertiesService.getUserProperties().getProperty('lastClick') and parse the result
If it is null or greater than 2 days from the current day, then the custom menu is added or enabled
Or 3 days, whatever
No I mean custom menu will be there but submenu will be deactivate for 2 days
09:09
Yeah, so just don't add the submenu
there may be a way to add it and disable it
which would be better, but you can still get by by not adding the menu at all
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('custom');
  // need to add if condition here but getting an error
   ui.addItem('Save', 'callSave');
    ui.addToUi();
}
check this line-
//need to add if condition here but getting an error
TypeError: Cannot find function addItem in object Ui.
the error seems self-explanatory
assign createMenu to a var and use that instead of ui
09:14
it means not permitted think finda hack
no. the variable ui does not know about addItem function
they're not equivalent. you're the original example is calling the function on the thing being returned by the call, and not on "ui"
you need a different object (as Ben has pointed out)
@BenFortune it worked.. thanks
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
     .alert(PropertiesService.getUserProperties().getProperty('lastClick'));
getting an error when submenu is clicked
Argument cannot be null: prompt
okay it means it is current day?
lastClick is what you set it to be
it doesn't exist until you set it, so it could be null initially
09:18
function onOpen() {
  var userProperties = PropertiesService.getUserProperties();
  var date = userProperties.getProperty('timestamp');
  var today = +new Date();
  var days = 3;

  var ui = SpreadsheetApp.getUi();

  var menu = ui.createMenu('Custom');
  // Need to add at least 1 item or it throws an error
  menu.addItem('First item', 'menuItem1');

  if(!date || date >= (today + (days * 24 * 60 * 60 * 1000))) {
    menu.addItem('Save', 'callSave');
    userProperties.setProperty('timestamp', today);
when the submenu item is clicked, you should be setting lastClick, not retrieving the value
@BenFortune that works except it demands atleast 1 submenu. But situation is when user clicks on start then button will be changed to stop for next 2 days and once 2 days are over then it will be turned to start
You have the resources, do it yourself
@Exception you have all the information you require to get it done now
yes doing...
09:27
Though reading about google script, it kinda really inspires me to do something neat with it
I'm sure as heck not relying on office ever again for scripting spreadsheets
oh geez, you can post a freakin' script webapp now..
09:46
userProperties.getProperty('timestamp');? Do this really exists because I am comparing date === today but it is returning false every time..
@Exception No! You're missing the point
The value of userProperties.getProperty('timestamp') is null until you set it
if you call userProperties.setProperty('timestamp', date), next time you call userProperties.getProperty('timestamp'), it will return the value of date
do you understand? It is storage info for you
gotcha
thanks
when document is loaded for the first time, it will not be set!
10:05
haha timestamp return is 1970
then you set it to 1970
I have to check whether date coming is 1970. if it is then show start button active
I'd think if you set it to "today", it would show some sort of date time as a string
if you want it to work down to the second, then at least the seconds must be saved somehow
if you only save the day, then your logic can only be precise down to the day
Hi. Anyone has used gulp-mocha before? I am trying to make a beep sound when my tests fail...any ideas how to do that...?
10:21
Fire that on .on('error', console.error)
that does not work if your volume mixer is off ...
or console got excluded.
you can filter applications to play sound or not
Well yeah, but with his requirements you'd expect him to have his volume on
can anybody tell me how a function would look like, where i can pass an array of functions wich is called in sequence?

from the input of: `[Math.log, Math.log]` and `[2, 3]`
the output should be the same as `[2, 3].map(Math.log).map(Math.log)`
@BenFortune are there any known issues on windows for this?
@deostroll Yeah, it won't work on windows
10:52
heh it just uses the bell character
not sure if it still works at win 10 o.o
nope 😕
> Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.
> In Windows 7, Beep was rewritten to pass the beep to the default sound device for the session. This is normally the sound card, except when run under Terminal Services, in which case the beep is rendered on the client.
TIL
aah got it working. I just had to use a frequency within hearing range <.<
11:10
Hey vue/symfony user.

I'm trying to create a little plugin and I was wondering if there was a better syntax than

:something='"{{ myTwigVar }}"' (notice the use of ' ")
11:25
hi , i've a question , i'm trying to run a function once something appears on the page or if URL change to a certain format basically , its a you-tube extension ( theme ) and i need to run some functions when the url change to something like {watch?v=SOMETHING } or if Video player (document.getElementsByClassName('html5-video-player')[0];) appears
Is it a chrome extension?
yes but i also have version of it in firefox , i guess they are not that different
11:38
any idea how i can event listener the look for that ?*
just check the url within the event listener?
could you explain this to me ?
currentUrl = window.location.href;
  if( window.location.href != currentUrl && !getJsonFromGivenUrl(currentUrl).hasOwnProperty("v") && firstTime == 1)
  {
what does "!getJsonFromGivenUrl(currentUrl).hasOwnProperty("v") && firstTime == 1" means ?
11:56
fellas which design patterns are you using?
@Deda 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.
How do I correctly add a class (using ElementRef) in Angular 7 to the contentTitle input box?
    if (this.formControls.contentTitle.errors) {
      this.el.nativeElement.contentTitle.addClass('has-error');
    }
I think i might actually need Renderer2?
if (this.formControls.contentTitle.errors) {
this.renderer.addClass(event.target, 'has-error');
}
wtf is contentTitle
formControlName
isn't addClass a jQuery method?
won't you want classList.add(...
12:06
no it replaced setElementClass in the old Renderer.
damn you, jQuery! You've struck again!
looks like jQuery but it is not. We are not using jQuery. Were not allowed to even say the word anymore. :)
This fixed my problem.
  validateWindowsSpecialCharacters(event: KeyboardEvent) {
    if (this.formControls.contentTitle.errors) {
      this.renderer.addClass(event.target, 'has-error');
    } else {
      this.renderer.removeClass(event.target, 'has-error');
    }
  }
@JoJo I was mostly kidding, but glad to hear it :)
:) It is like a lost my mother... but I will survive hehe
This could probably be refactored:
  validateWindowsSpecialCharacters(event: KeyboardEvent) {
    if (this.formControls.contentTitle.errors) {
      this.renderer.addClass(event.target, 'has-error');
    } else {
      this.renderer.removeClass(event.target, 'has-error');
    }
  }

  ngOnInit() {
    this.contentForm = this.formBuilder.group({
      contentTitle: [null, [
        Validators.required,
        Validators.pattern(/^[^*|?:<>\\/"]+$/)]]
    });
  }

  get formControls() { return this.contentForm.controls; }
Hello everyone, Im here b/c HTML room is dead right now.
On Blueimp jQuery file upload UI there is a left and right arrow but they're not < or > or &lt; or &gt; So what are they and how do I replicate them from the keyboard?
Copied directly from source
<a class="prev">‹</a> <a class="next">›</a>
and visually, they are much prettier than everything else
12:15
ascii maybe?
I just copied them from source and am using them as is unless someone says theyre taboo
JoJO, I dunno, wouldn't it then be in form of &gt;?
ok I"m starting to pull out the last few hairs on my head.
@Stuart seems a different character
Id feel even better if I knew how to replicate from the keyboard
Hmm I C
that seems a smaller greater/less than icon
gotcha dig in the unicode chart
12:17
How can it be that on normal ubuntu flow-remove-types installed "globally" callled through flow-remove-types api/utilites.js does remove %checks function hints. yet when I run it in an (alpine linux) docker it doesn't?
Both are running flow-bin 0.102.0-rc and flow-remove-types 2.101.0
Karel, wouldnt it then be as such or similar
&gt;
in the source
weird
no that gives > which is different to ï¹¥
These things turn me crazy after spending a full day on it, and I have to admit I'm kind of out of options.
there are others as well
12:19
Karel, Its amazing how you were just able to replicate it in chat
Well I was aware &gt; = > but I was wondering shouldnt the source be similar?
Anyways... Thanks for the clarification that it is legit, I just dont know how he made the smaller appear in the source like that
and whats crazier is that viewed live is the ends are spread much further apart than &gt; or >
making it much more appealing for a next arrow
smaller in source but much larger live with no css
larger live than &gt; or >
Yall take care
12:54
hey how can i detect the dom of herf ?
like youtube.com or facebook.com
var x = youtube.com
var y = facebook.com
current = window.location.href

if ( check if current does have x or y and (some string) )
how can i do that ?
try window.location.hostname
or actually you probably want window.location.pathname
good boy Neil
13:33
Hey all
long long time eh !
Lol you still didn't forget me :L
the old clan getting back together eh
What you guys think about having a NodeJS \ Express Web Service, along with lokijs...

The purpose of this web service is to act as a man in middle between several different clients and a cloud CRM, which has it's own OData based web services ?

Loki is used to cache data...

Not something I architect, but I feel like there something isn't right about it, Could you help to identify that ?
you'll have to be more specific
13:39
sure, what else you want to know
at first, it's the idea of having a man in middle which isn't going down my throat, second is the caching with loki.js...
well that may be exactly what you need
I don't know what your requirements are
which part isn't right?
that he did not use tom hiddleston himself to manage that
14:05
how to trigger click without user click ..
I have one menu structure when user click on one particular box it do some operation.
.click()
Hi Ben. Did you happen to find anything else wrong with the bot if you looked?
Ok thanks,Let me try if I can able to get an element..
<div class="customdown ">
                                    <a id="analysisLabel" role="button" data-toggle="dropdown" class="btn btn-primary btype  main_menutype first-check" data-menu="analysis" data-target="javascript:void(0)" selectedindex="1" href="/page.html" aria-expanded="true" style="pointer-events: all;">Expected GCL Forecast</a>
                                    <div class="customdroptry">
                                        <div class="menuDisplayOverlay menuoverlay dropstyle" id="anlysis_menuDisplay" style="display: block;">
I want to click on data part a, how I can do that.. @Neil
@Sheel where is data part a?
you mean analysisLabel?
14:18
data part means id=analysisDropDown
document.getElementById('analysisDropDown').click();
where data-id="e6-----"
you shouldn't have more than one element with that id you know
use class if you want to do that
ok let me try
hey , i have chrome extension that have this code in it.
document.addEventListener("DOMContentLoaded", () => {
  console.log("working"); }
it doesn't run
14:21
can we manage this click.. because I want to perform this operation $('#anlysis_menuDisplay ul li a').on('click', function() { });
@AndonMitev 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.
15:03
I got some help from @JBis regarding this recursive function to count vowels in a string:
function countVowels(string) {
  if (string.length === 0) {
    return 0;
  }
  else {
    let count = 0;

    if ((string[0].match(/[aeiou]/i))) {
      count ++;
    }

    count += countVowels(string.slice(1))
    return count;
  }
}

console.log(countVowels("helloWorld"));
But I am not understanding
count += countVowels(string.slice(1))
Why is the recursive call to slice the string's first character getting added to the count, here?
I would have just expected:
function countVowels(string) {
  if (string.length === 0) {
    return 0;
  }
  else {
    let count = 0;

    if ((string[0].match(/[aeiou]/i))) {
      count ++;
    }

    countVowels(string.slice(1))
    return count;
  }
}
Which still seems to work, actually
To understand such things you'd do best by just taking a "test" run and walking through it.
(manually)
Say input is "hi":

countVowels(hi)
    let count = 0; //count = 0
    //string[0] = 'h'
    //count stays "0"
    //string.slice(1) = 'i'
    countVowels('i')
        let count = 0; //scoped(!) count is 0 again. This is a different variable than the other.
        //string[0] = i
        count ++; //count is increased to 1
        //string.slice(1) = ''
        countVowels('')
            //string.lenght === 0
            return 0;
        return count; // return 1
    return count; // return 0 notice scoped count is a different count than the one of the recursive function
So to actually use the result of the recursive calls, and not just throw them away, we need to do something with it.
(ie add to the count)
If "scope" as used here is an alien word to you, I suggest you google that. - It's when starting a difficult to grasp subject, too broad to be explained by my correct and easily: but of vital importance for any programming you do.
15:30
Interesting okay so the count within the recursive scope is different from the count outside of it.
indeed that is the definition of a scoped variable.
In constast to global variables. (and in javascript there's also the var declared which are global to the "script", but I'd actually just evade those until you at least have a very good understanding on this subject).
is firefox becoming the new IE11 with obsessive security measures enabled by default
16:24
@KevinB ?
what obsessive security measures
all of them
also I'm not sure that's an accurate framing
I want my browsers to be secure by default.
If browsers really wanted to be secure, they would kill the window.open api, and block all ads
16:44
err,
Firefox should ship with a link to uBlock Origin already in the bookmark toolbar
Jon Ericson on June 18, 2019

Analytical

Documentation badges

Tumbleweed and Reversal

Julia Silge’s analysis demonstrated that the Tumbleweed badge wasn’t serving its purpose.

Meg Risdal is our Product Manager who led us to make these changes.

Jane Willborn wrote the code.

Nick Craver made sure the Lifejacket and Lifeboat triggers don’t break the site.

Ben Voigt suggested the trigger we used first for Winter Bash hats and now for two new badges.

A bunch of people tested those triggers on our sites and prodded us to keep considering something like these new badges. We also got a bunch of feedback about Reversal and especially Tumbleweed that helped us understand how they worked in practice. We’ve got an amazing community here! …

reversal was unfriendly, so we added in two new badges that do the same thing!
correlation is not causation
Stack Overflow has a lot to learn
17:26
I have a pattern attribute on an input box that does not allow a question mark for example.
In writing Jasmine tests for this, how can I test for the :invalid pseudo selector on the element?
  it('should have :invalid selector if input value conatins windows special character', () => {
    const hostElement: HTMLElement = fixture.nativeElement;
    const inputElement = hostElement.querySelector('input');
    inputElement.value = '?';
    console.log(inputElement);
//    expect(inputElement).toBe(Invalue);
  });
inputElement.parentNode.querySelector('input:invalid') === inputElement
oh my lord @ndugger will try it. Thank you. Searches were a pain...
It's just an idea; there may be other ways
yes.. trying just this:
expect(inputElement.parentNode.querySelector('input:invalid')).toBeTruthy();
  it('should have :invalid selector if input value conatins windows special character', () => {
    const hostElement: HTMLElement = fixture.nativeElement;
    const inputElement = hostElement.querySelector('input');
    inputElement.value = '?';
    console.log(inputElement);
    expect(inputElement.parentNode.querySelector('input:invalid')).toBeTruthy();
  });
It works. I change inputElement.value = 'a'; and it fails
woot!
will play with it
Hey guys ! I want to change the 'lastname' property to UpperCase of this array of objects, using destructuring
const array = [
  {
    name: 'Eddy',
    lastname: 'Brown',
    age: '30',
    birthday: '1989-04-01',
    id: 'T14-38-20-393',
    groupId: 'T-354GK7-001'
  },
  {
    name: 'Ana',
    lastname: 'Smith',
    age: '25',
    birthday: '1994-03-19',
    Id: 'T19-50-21-543',
    groupId: 'T-354GK7-002'
  }
];
To do that I do:
array.map(({ lastname, ...rest }) => ({ lastname: lastname.toUpperCase(), ...rest }));
And I get this:
[
  {
    lastname: 'BROWN',
    name: 'Eddy',
    age: '30',
    birthday: '1989-04-01',
    id: 'T14-38-20-393',
    groupId: 'T-354GK7-001'
  },
  {
    lastname: 'SMITH',
    name: 'Ana',
    age: '25',
    birthday: '1994-03-19',
    Id: 'T19-50-21-543',
    groupId: 'T-354GK7-002'
  }
]
Now, 'lastname' is in the first position. I need on it's original position, 2nd place
It is possible without doing 'hard coding' every property to keep the order?
17:39
I'm getting this weird problem in Vue and i can't see what's causing it.
I have the following code
@ndugger Thanks!!
1 message moved to Trash can
@Hypersapien Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
<p id="errorList" v-if="errors.length > 0">
    <ul>
        <template v-for="error in errors"><li>{{ error }}</li></template>
    </ul>
</p>
<button v-if="currentSearchType != null" v-on:click="doSearch">Search</button>
using vue is its own problem
I DID hit CTRL-K the first time
17:41
should the v-for be error of errors? I don't know what vue is doing, so I don't know
errors is an array in the vue object
right, but you probably want a for..of, not a for..in
I don't know what magic voodoo vue does with it's god awful custom markup, so I don't know
but I doubt that for..in is what you want
When there's no errors in the list, I get this
<ul></ul>
<p></p>
<button>Search</button>
With an error I get this
<p id="errorList"></p>
<ul>
	<li>Please enter a partial First Name or Last Name</li>
</ul>
<p></p>
<button>Search</button>
18:02
ok, so nevermind. I don't know yucky vue
the future is now, old man
    class Bot {
        constructor(client) {
            [...]
            this.client.on(ChatEvent.NEW_MESSAGE, this.processMessage);
            this.client.on(ChatEvent.EDIT, this.processMessage);
        }
        async processMessage(msg) {
             [...]
            this.validatorScriptRunner(msg)
            [...]
          }
        [...]
    }
Do I need to bind this.processMessage in the on function?
So it would be
this.client.on(ChatEvent.NEW_MESSAGE, this.processMessage.bind(this));
why or why not?
18:23
@Hypersapien jsfiddle where your code is working
wait I see the problem
@JBis well, yes, because that's how it works?
Hypersapien the issue is that you're using p elements around non-text
if your function depends on this, you need to be conscious of how you define/use it to make sure it keeps the correct reference of this.
change it to a div and it works fine
@KevinB so what will this refer to (in processMessage) if I don't bind it?
18:25
depends on what this.client.on does.
Does it set a context on the event handler?
who knows
1199
Q: How does the "this" keyword work?

Maxim GershkovichI have noticed that there doesn't appear to be a clear explanation of what the this keyword is and how it is correctly (and incorrectly) used in JavaScript on the Stack Overflow site. I have witnessed some very strange behaviour with it and have failed to understand why it has occurred. How doe...

but you can be sure it will not refer to an instance of Bot
ok
thank you
because client.on can't access the this client is referred from
How would I pass an instance of Bot to an instance of Client?
so within Client class I can do this.bot.someFunc()
you wouldn't
you'd pass it to the callbacks
What do you mean?
18:32
client doesn't need to know that it's dealing with bot instances
you have two primary options:
    class Bot {
        constructor(client) {
            this.processMessage = this.processMessage.bind(this);
            [...]
            this.client.on(ChatEvent.NEW_MESSAGE, this.processMessage);
            this.client.on(ChatEvent.EDIT, this.processMessage);
        }
        async processMessage(msg) {
             [...]
            this.validatorScriptRunner(msg)
            [...]
          }
        [...]
    }
Oh. This is a separate question. Not about binding the processMessage.
My problem is I have certain instantiated Bot functions that need to be called from the instantiated Client.
If that makes sense
so a circular reference
the bot instance currently has a reference the client instance, and you also want to have the reverse
I tend to avoid that kind of setup, as it makes importing things complicated.
but it's possible
How could I avoid the circular reference then? Also what things can become complicated?
for example, if you decided to split the classes into their own files, A imports B, and B imports A
which... is a problem
Not sure if this helps but a specific example is the following. Bot class has a saveData function that saves things in difference places depending on how the Bot is instantiated. Client needs to use that saveData function. I could try to pass a Bot in the Client constructor.
@KevinB yeah I see what you mean
bot = new Bot();
bot.client = new Client(bot);
But that seems stupid
18:51
Anyone know about native modules in node?
probably
but i don't recognize that terminology
how do I pass a string to V8::string and set it to my return value in the args.GetReturnValue()
V8::string("asdfasdf")?
1 message moved to Trash can
@Rick Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
I've never tried to work with V8
18:59
yeah I tried but it fails
00:00 - 19:0019:00 - 00:00

« first day (3167 days earlier)      last day (2004 days later) »