I’m trying to use ES6 modules in Chrome. From all the examples I’ve looked at the following seems to be the right way to do it, but when I run it in Chrome’s developer tools I get this error message… uncaught SyntaxError: Unexpected token { …highlighting the import statement in t…
Tag: javascript
How do I fix a div scroll to make it more smooth?
So I started off with having a problem on mobile phones where I had a div over the main page and whenever I scrolled on that div I would also be scrolling the whole page. I found a fix for this problem from this post as follows: This fixed the problem for me but also created another problem. This fix
How to access the value of baseURL in Cypress
I’m just starting to learn JavaScript and have been using Cypress to automate some regression tests. The test I writing currently is meant to verify link’s text and href in a header and footer. The issue I am having is that these tests need to be run across various environments and I cannot seem t…
javascript equivalent of jquery all children selector
I have the following jquery selector which I am trying to convert to regular javascript. what would the equivalent be with regular javascript ? Can I do this ? Answer One elegant, non-jQuery way to do this would be via querySelectorAll():
Getting next element in a table javascript
https://jsfiddle.net/en6jh7pa/1/ I am having issues grabbing the next element, it is returning null for the next element. I am passing “this? as onclick and I assumed that you could use this to grab the next element but it seems that it instead returns null Thanks for your help Answer If you want to get…
How can I get my bot to send a message to another channel?
so I have a bot that takes whatever I say when I do the command /say and deletes my message. Since it still technically sends my message, people will see it through notifications and can tell that it was me that got the bot to send the text. I am doing this as a fun and troll thing with my
ES6: fire React function
This is the code: What I am trying to do is to fire the updateNews code from render: But keep getting this error: Uncaught Error: this.updateNews is not a function Answer You were not calling the functuion Note: You do need to bind because you use arrow function.
What is this piece of Javascript for Isotope filter doing?
I am having some trouble understanding what is happening in a piece of vanilla JS for the Isotope filter. The original code is here: https://codepen.io/desandro/pen/VWLJEb What is happening between the getOnButtonGroupClick function and it being assigned to a variable in the for loop preceding it? Answer getB…
Is it possible to interpolate Javascript regex match in a string template?
For example… (this fails) Is there a way to make this sort of thing work? $1 is available when it’s used in a string, but not as a key. Answer Unfortunately no, you’ll have to use a replacer function instead: Also note that you can use d instead of [0-9] instead, it makes the regex a bit nic…
UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
I am getting this huge error running a Mocha test with node version 10 and a MongoDB database: (node:27884) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value: assert( user.blogPosts[0].comments[0].content === ‘As programs get bigger, they also be…