var data = {
types: {
type_1: {
max_speed: 300
},
type_2: {
max_speed: 260
}
},
TC: {
transport_1: {
color: "red",
type: "type_2"
},
transport_2: {
color: "blue",
type: "type_1"
}
}
}
var tc = data.TC.transport_1;
console.log("Car:", tc.color); //red
console.log("Speed:", data.types[tc.type].max_speed); //260
{
"types": {
"type_1": {
"max_speed": 300
},
"type_2": {
"max_speed": 260
}
},
"TC": {
"transport_1": {
"color": "red",
"type": "type_2"
},
"transport_2": {
"color": "blue",
"type": "type_1"
}
}
}
let style = document.createElement('style');
style.innerHTML = `
div {
animation-name: nodeReady;
animation-duration: 0.001s;
}
@keyframes nodeReady {
from { clip: rect(1px, auto, auto, auto); }
to { clip: rect(0px, auto, auto, auto); }
}
`;
document.head.appendChild(style);
document.addEventListener("animationstart", function(e) {
if (e.animationName == "nodeReady") {
if (e.target.innerHTML.trim() == 'привет') e.target.innerHTML = 'Пока';
}
}, false);
.mydiv {
animation-name: nodeReady;
animation-duration: 0.001s;
}
document.children[0].appendChild(style);
try{ eval("let x"); alert("ES6+"); } catch(e) { alert("ES5-"); }
=OR(D7;F7)
\/\w+\/[0-9]+
<?php
$arr = [100,125,75,175,25,300,275,325,375];
$step = 50;
$b = []; //-1 - deny, 0 - not set, 1 - has interval
$int = []; //intervals if necessary
$step2 = intdiv($step,2);
$arr = array_values(array_filter($arr, function($v) use ($step2,&$b,&$int) {
$i = intdiv($v,$step2);
$mod = $v % $step2;
$res = true;
if (isset($b[$i])) {
if ($b[$i] === -1) $res = false;
elseif ($mod < $int[$i][0] or $mod > $int[$i][1]) $res = false;
}
$b[$i] = -1;
$b[$i+1] = -1;
$b[$i-1] = -1;
if (!isset($b[$i+2])) {
$b[$i+2] = 1;
$int[$i+2] = [$mod,$step2];
} elseif ($b[$i+2] === 1) {
if ($int[$i+2][0] < $mod) {
$int[$i+2][0] = $mod;
if ($int[$i+2][0] >= $int[$i+2][1]) $b[$i+2] = -1;
}
}
if (!isset($b[$i-2])) {
$b[$i-2] = 1;
$int[$i-2] = [0,$mod];
} elseif ($b[$i-2] === 1) {
if ($int[$i-2][1] > $mod) {
$int[$i-2][1] = $mod;
if ($int[$i-2][0] >= $int[$i-2][1]) $b[$i-2] = -1;
}
}
return $res;
}));
var_dump($arr); // [100, 175, 25, 300, 375]
?>
=
function bouncer(arr) {
// Don't show a false ID to this bouncer.
for(let i=0;i<arr.length;i++) {
console.log("Индекс:",i,"Значение:",arr[i]+'',"Отрицание:",!arr[i]);
if (!arr[i]){
arr.splice(i,1);
console.log("Сработало условие, новый массив:",[...arr]);
}
}
console.log("Итоговый результат:",arr);
return arr;
}
bouncer([0, false, 7, "ate", "", false, 9, NaN]);
i--
, либо перебирать массив с конца к началу:function bouncer(arr) {
// Don't show a false ID to this bouncer.
for(let i=0;i<arr.length;i++) {
console.log("Индекс:",i,"Значение:",arr[i]+'',"Отрицание:",!arr[i]);
if (!arr[i]){
arr.splice(i,1);
i--;
console.log("Сработало условие, новый массив:",[...arr]);
}
}
console.log("Итоговый результат:",arr);
return arr;
}
bouncer([0, false, 7, "ate", "", false, 9, NaN]);
function bouncer(arr) {
// Don't show a false ID to this bouncer.
for(let i=arr.length-1;i>=0;i--) {
console.log("Индекс:",i,"Значение:",arr[i]+'',"Отрицание:",!arr[i]);
if (!arr[i]){
arr.splice(i,1);
console.log("Сработало условие, новый массив:",[...arr]);
}
}
console.log("Итоговый результат:",arr);
return arr;
}
bouncer([0, false, 7, "ate", "", false, 9, NaN]);
3,14
;
и проблема будет решена.let point = {
// .....
}; // <-----
()
point.properties.color == 'red'? dangerPoints.features.push(point): points.features.push(point);
let x=5
(x)?1:2; //error
let x=5;
(x)?1:2; //ok
let x=5
x?1:2; //тоже ок