Quantcast
Channel: User Ben Aston - Stack Overflow
Browsing all 43 articles
Browse latest View live

Comment by Ben Aston on In JavaScript, how can I conditionally assign value...

const { lastName } = objA || objB;: objA is truthy, and so it is the result of the OR operator. And it doesn't have a lastName property, hence the destructured variable lastName remains undefined.

View Article



Comment by Ben Aston on In JavaScript, how can I conditionally assign value...

OR returns the first truthy operand, or the second falsy operand

View Article

Comment by Ben Aston on JavaScript Date - How to better set midnight UTC+0

If you want to treat everything as UTC, and if you can get the raw day, month, year values out of the date picker, the Date constructor assumes UTC when supplied with a string with no time component;...

View Article

Comment by Ben Aston on JAVASCRIPT Reload a page or a div using JS

location.reloadwill not bypass the browser's cache.

View Article

Comment by Ben Aston on js count coming up as Nan within html elements

NaN is produced when a string is converted to a Number, but that string does not contain a parseable number. Check for this.

View Article


Comment by Ben Aston on How to use vanilla script to bounce elements from...

Create two elements. Position them absolutely so you have precise control over their location on the page. Use getClientBouningRect to determine the precise location of the edges of the element. Use...

View Article

Comment by Ben Aston on setInterval's interval always changes to 1 second...

There are a bunch of reasons why an interval might be longer than expected. They are outlined here. setInterval follows the same rules as setTimeout.

View Article

Comment by Ben Aston on How to wait a function to finish completely before...

You probably need to promisify downloadVideo and return the promise (with resolve linked to the exit event).

View Article


Comment by Ben Aston on Why can I use an arrow function before it's declared...

In the first example, invocation of settingsDataAvailable(...) occurs at minimum one microtask later due to the presence of an await. This means that the synchronous top-level evaluation of the entire...

View Article


Comment by Ben Aston on Should I use px or rem value units in my CSS?

While it is true that browser "zooming" technique changed over the years, having a relative font-size (like rem) is not about zooming per-se: it's about user style sheets and their effect. People with...

View Article

Comment by Ben Aston on Is it possible to store a button value from a click...

A callback function is only run when a button is pressed. In your first example, the console.log is evaluated before any button is pressed, and is therefore printing undefined.

View Article

Comment by Ben Aston on What is the point of void operator in JavaScript?

You're dancing on the head of a pin about ES1.3 vs JS1.3? Wow. oreilly.com/library/view/javascript-the-definitive/059600048‌​0/…

View Article

Comment by Ben Aston on What are the greyed-out messages in the Chrome console?

Yes, thank you.

View Article


Comment by Ben Aston on Updating a function stored in a ref, using useRef

It's that simple?

View Article

Image may be NSFW.
Clik here to view.

Answer by Ben Aston for valueOf() vs. toString() in Javascript

TLDRType coercion, or implicit type conversion, enables weak typing and is used throughout JavaScript. Most operators (with the notable exception of the strict equality operators === and !==), and...

View Article


Answer by Ben Aston for JS / Array of Objects / cut by condition values in...

Pseudocode:Transform the data to remove everything between words 'C' and 'T'.'retrieval' is a mode that pulls items into a new array.'retrieve' is the action of pulling an item into a new...

View Article

Answer by Ben Aston for Function works only in Safari, other browsers throw...

window.changeLabel === 'undefined' will return false regardless of browser because you are comparing a property value with the string 'undefined' and not the value undefined.In Safari's sloppy mode the...

View Article


Answer by Ben Aston for Extends behaviour in js with default value

In your first example, the creation and initialization of the public instance field named defaultValue in Child occurs after the creation and initialization of the public instance field named value in...

View Article

Importing styles into a web component

What is the canonical way to import styles into a web component?The following gives me an error HTML element <link> is ignored in shadow tree:<template><link rel="style" href="foo.css"...

View Article

Explanation of Epsilon in IEEE 754

Epsilon is the smallest value in a number encoding scheme that can be added to 1 to generate a number that has a distinctly different representation.Can anyone help me intuit why the loss of precision...

View Article
Browsing all 43 articles
Browse latest View live




Latest Images