'disp' is already defined
108 else if (window.getComputedStyle)
109 {
110 // For most other browsers
111 var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');112 }
113
114 // Toggle the state of the "display" style
'disp' is already defined
103 else if (elem.currentStyle)
104 {
105 // For MSIE, naturally
106 var disp = elem.currentStyle['display'];107 }
108 else if (window.getComputedStyle)
109 {
'id' is already defined
39 // Hide all content divs except the first
40 var i = 0;
41
42 for (var id in contentDivs) 43 {
44 if (i != 0)
45 {
'id' is already defined
23 // highlight the first tab
24 var i = 0;
25
26 for (var id in tabLinks) 27 {
28 tabLinks[id].onclick = showTab;
29 tabLinks[id].onfocus = function () {
'i' is already defined
37 }
38
39 // Hide all content divs except the first
40 var i = 0; 41
42 for (var id in contentDivs)
43 {
'i' is already defined
21
22 // Assign onclick events to the tab links, and
23 // highlight the first tab
24 var i = 0; 25
26 for (var id in tabLinks)
27 {
Description
The var
keyword is soft-deprecated, and should not be used to redeclare existing variables.
It is possible to re-declare the same variable using the var
keyword:
var a = 1;
var a = 10; // valid!
However, this can have unintentional side effects on the code:
var x = 10;
{
var x = 20;
}
console.log(x); // 20
Bad Practice
var db = dbDriver.loadTables()
{
var db = db.get("usersId:1234") // bad practice!
}
Recommended
// always use 'let' or 'const'
const db = dbDriver.loadTables();
{
const users = db.get("userId:1234") // avoid shadowing
}