Answer the question
In order to leave comments, you need to log in
Why in some js guides do the authors deliberately not put a semicolon?
In some guides, the authors do not put a semicolon at the end of the instructions. Why do they do it? Is this a feature of Babel?
// Send a request to the login URL and save the returned JWT
login(context, creds, redirect) {
context.$http.post(LOGIN_URL, creds, (data) => {
localStorage.setItem('id_token', data.id_token)
this.user.authenticated = true
// Redirect to a specified route
if(redirect) {
router.go(redirect)
}
}).error((err) => {
context.error = err
})
},
Answer the question
In order to leave comments, you need to log in
Possibly demonstrate the advantage of language. Because at the compilation stage, he himself substitutes a semicolon where necessary. Although I myself don’t understand why they still don’t write in strict mode) As they say, it’s better to be safe than sorry.
Syntactically, this is correct, but at some points the code will not work.
For example:
alert( "Error" )
[1, 2].forEach(alert)
Are Semicolons Necessary in JavaScript?
And yes, for sure Aves is right.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question