Should you use var or let?



Should you use var or let?..

Answer / Ashutosh Sahu

In modern JavaScript, it is recommended to use 'let' or 'const' instead of 'var'. 'var' has function-scoped declaration and can lead to issues like variable hoisting and unintended global pollution. 'let' and 'const', on the other hand, have block scope.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

program showing string concatenation?

4 Answers  


Explain the term closure?

1 Answers  


How we can add title of the page by javascript?

1 Answers  


What is the use of window object?

1 Answers  


Is Javascript a Functional Programming Language?

1 Answers  


What is the difference of "settimeout" function and setinterval functions in javascript

1 Answers  


Can you access Cookie using javascript?

1 Answers  


What causes memory leaks?

1 Answers  


How to set the focus in an element using javascript?

1 Answers  


What is unshift method in JavaScript?

1 Answers  


What is NaN in Javascript?

1 Answers  


Describe javascript and vbscript.

1 Answers  


Categories