Javascript Password I How to show password in javascript #html #webdesign #coding #js #javascript

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

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

Nice, but I'd add some refactoring:

Instead of using getElementById, better to use querySelector (it's quicker and more comprehensible), instead of var I'd likely use let, instead of writing big if-else block with redundancy I 'd just use js-like inline statement and finally would use arrow func. So:

Document.querySelector('#togglePassword').addEventListener('change', () => {

Let passwordInput = querySelector('#password')

PasswordInput.type = this.checked ? 'text' : 'password'
}

And that's it 😊
Happy hackin 😅

AR-ozuw
Автор

Some very important, when a variable is declared as var, the variable remain global, and in large amount of code, one or more variables can make break the program, and for this, declare with let, and the variable remain how local, allowing use a name of a variable how concept in any function when be necessary.

sergioacuna
Автор

Is VAR still used in modern codes? Or it i understand it incorrectly? I'm not a programmer yet, jus studying

binboom
Автор

ok first of all why are you using inline script tags just use a separate file and second why are you using var and third: stop using chatgpt to write code for you 💀

Lenn
visit shbcf.ru