Why is JavaScript ASI like this? #javascript

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Or you can put the semicolon after points declaration, like normal people.

wlan
Автор

Rookie mistake really. I spotted it right away. You are using js.

collinb
Автор

not requiring semicolons is a stupid design choice, and we should just pretend they aren't optional.

AwesomeTingle
Автор

i always put a semicolon. this video being another example of the headache it saves you

InanIsmailov-jlos
Автор

Putting a semi colon before that statement was just trying too hard to be hipster

kesogonzaga
Автор

For all of you python users (we love you) the reason it crashes is because the whole code is interpreted as one line.

brainloading
Автор

This is interesting, I am practicing JS and TS and these kind of content enlightens me on what I don’t know haha

tunacant
Автор

To destructure add a variable declaration (const) before the array and us curly braces instead of square brackets

NoobietheGamer-xslc
Автор

The ultimate answer why I should go back to putting semi-colons after statements in JS. I assume this will also be the case in TS.

tutonjason
Автор

And this ladies and gentlemen is why people make fun of javascript

MannysTechWorld
Автор

The bug is that no one in their right mind would reverse an array like that. All of JavaScripts quirks are just trivia, people who use code with the bread and butter of JavaScript which works great

JackAttack-jnop
Автор

All of those cases are perfectly explainable by the angine not recognizing the end of the statement. You know the thing semicolons are for. Also the thing that's mandatory in most non white space sensitive languages to prevent ambiguity and weird errors.

Автор

JS is only in the users browser. That's it. It is the language I don't wanna use for anything else.

saidjonrko
Автор

People who not using semicolons should not allowed to code in js.

razor-eg
Автор

Just put semicolon on every single line, or comma except for a function declaration, javascript is not compiled programming so you will never know the problem until you run it

ThierryTeen
Автор

From the beginning it was solved simply by putting the semicolon after the first line... Like this:

let points = [3, 7];
[points[0], points[1]] = [points[1], points[0]]
console.log(points)

This happens because when you start the 2nd line with '[' javascript "believes" that it is the continuation of the first one.
PS: I'm not a fan of javascript, but don't make it any worse than it already is😅)

AdrianAlejandroSoutoMorales
Автор

I was Programming in Python in the Last Date and didn’t catch the missing semicolons at all 😅

JockelGaming
Автор

JavaScript. Never type-spaced except when it comes to return and switch statements.

Michael-Martell
Автор

Wait, WHAT. Need so much more information.

kingbbiv
Автор

Or you can also try points.reverse()

Let points = [3, 7];

Points.reverse() //Output [7, 3]

thulanimthembu