Error message

  • Deprecated function: Return type of DatabaseStatementBase::execute($args = [], $options = []) should either be compatible with PDOStatement::execute(?array $params = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2244 of /home/xenoveritas/xenoveritas.org/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home/xenoveritas/xenoveritas.org/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home/xenoveritas/xenoveritas.org/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home/xenoveritas/xenoveritas.org/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home/xenoveritas/xenoveritas.org/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home/xenoveritas/xenoveritas.org/includes/database/database.inc).

JavaScript

JavaScript Closures and Loops

JavaScript closures can be kind of weird. The way a closure works within a loop is a fairly common "gotcha" because it doesn't work in the way that it intuitively feels like it should.

Take the following block of code:

for (var i = 0; i < 5; i++) {
    var button = document.createElement("button");
    button.innerHTML = "Button #" + (i + 1);
    button.onclick = function() {
        alert("You clicked on " + button.innerHTML + "!");
    };
    document.body.appendChild(button);
    document.body.appendChild(document.createElement('br'));
}

What does that do? Read More to find out.

Topics: 
Subscribe to RSS - JavaScript