Skip to content

Latest commit

 

History

History
40 lines (35 loc) · 607 Bytes

ForStatement.md

File metadata and controls

40 lines (35 loc) · 607 Bytes

For Statement

For Statement

let b = 1;
for (let i = 0; i < 10; i++) {
    b += 10;
}

const a = [1, 2, 3];
for (const iterator of a) {
    console.log(iterator);
}

const d = {a: 1, b: 2};
for (const iterator in d) {
    if (d.hasOwnProperty(iterator)) {
        console.log(iterator);
    }
}
$b = 1;
for ($i = 0; $i < 10; $i++) {
    $b += 10;
}
$a = array(1, 2, 3);
foreach ($a as $iterator) {
    echo $iterator;
}
$d = array( "a" => 1, "b" => 2 );
foreach ($d as $iterator => $__ts2php_item) {
    if (array_key_exists($iterator, $d)) {
        echo $iterator;
    }
}