Why is `(foo) = “bar”` legal in JavaScript?

It’s valid indeed. You’re allowed to wrap any simple assignment target in parenthesis. The left hand part of the = operation is a LeftHandSideExpression as you correctly identified. This can be tracked down through the various precendence levels (NewExpression, MemberExpression) to a PrimaryExpression, which in turn might be a Cover­Parenthesized­Expression­And­Arrow­Parameter­List: ( Expression[In, ?Yield] ) (actually, … Read more

Why is String.prototype.substr() deprecated?

Because it’s never been part of the standardized language. It wasn’t in the ECMAScript 1 or 2 specs at all, and only appears in ECMAScript 3 in Section B.2 (“Additional Properties”) (and subsequent editions in similar annexes through to today [ES2022 draft as of this writing]), which said:¹ Some implementations of ECMAScript have included additional properties for … Read more

How to wait for a JavaScript Promise to resolve before resuming function?

I’m wondering if there is any way to get a value from a Promise or wait (block/sleep) until it has resolved, similar to .NET’s IAsyncResult.WaitHandle.WaitOne(). I know JavaScript is single-threaded, but I’m hoping that doesn’t mean that a function can’t yield. The current generation of Javascript in browsers does not have a wait() or sleep() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)