myVariable && (myVariable - 35)
[100, 0, null, '', true, false, 'gdfsg'].map(n => [n ? n - 35 : n, n && (n - 35)]);
/*
0:(2) [65, 65]
1:(2) [0, 0]
2:(2) [null, null]
3:(2) ["", ""]
4:(2) [-34, -34]
5:(2) [false, false]
6:(2) [NaN, NaN]
*/
(n => n && (n - 35))(myVariable)
var pattern = /{: 5 \+ 5 :}/g
let anotherObj = Object.assign({}, obj)
$arr1 = [1,2,3,4,5,6,7,8,9,10];
$arr2 = [2,3];
$arr3 = array_diff($arr1, $arr2);
$undiff_count = count($arr1) - count($arr3); //Нужно число выкинутых, а не оставшихся
$similiar_count = $undiff_count * 100 / count($arr1);
echo 'Схожесть массивов ' . $similiar_count .'%';
$arr = array(
[0] => 1;Изделие из золота №001;1325;1235;15
[1] => 2;Изделие из золота №002;1425;1425;15
[2] => 3;Изделие из золота №003;1300;1100;0
);
$newarr = [];
foreach ($arr as $item) {
$item = explode(';' , $item)
$arritem = [];
list ($arritem['ID'] , $arritem['NAME'] , $arritem['PRICE'] , $arritem['DISCOUNT_PRICE'] , $arritem['AMOUNT']) = $item;
$newarr[] = $arritem;
}
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
// использование
ready(function(){
alert("DOM fully loaded and parsed");
});
const example = {
"sample": {
"someitem": {
"thesearecool": [
{
"neat": "wow"
},
{
"neat": "tubular"
}
]
},
"coolcolors": [
{
"color":"red",
"hex": "ff0000"
},
{
"color":"blue",
"hex":"0000ff"
}
]
},
"1": {
"some": "item"
}
}
// [ { neat: 'wow' }, { neat: 'tubular' } ]
example.sample.someitem.thesearecool
// [ { color: 'red', hex: 'ff0000' }, { color: 'blue', hex: '0000ff' } ]
example.sample.coolcolors
// { some: 'item' }
example["1"]
.length
в вашем примере. У вас, скорее всего, консольлог с length вызывается раньше цикла.||
в своем переборе, где Вы пушите результат, почему нет?const arr = [{test1: 1, test2: 2}, {test1: 1}, {test1: 1, test2: 2}];
arr.forEach(function(item, i, arr) {
console.log('Test1: ' + (item.test1 || 'Empty'));
console.log('Test2: ' + (item.test2 || 'Empty'));
});
//Test1: 1
//Test2: 2
//Test1: 1
//Test2: Empty
//Test1: 1
//Test2: 2
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L,QSA]
$output .= $results['status'] == 2 ? "offline" : "online";
$output .= PHP_EOL;
$output.="".$results['status']."
";
return +a[attr] > +b[attr] ? 1: -1;
return +a[attr] - b[attr];
const sortFunc = function sortFunc(data, elem) {
switch( elem.getAttribute('name')) {
case 'id':
case 'salary':
data.sort((a, b) => +a[attr] - b[attr]);
break;
case 'user':
case 'position':
case 'gender':
data.sort((a, b) => a[attr] > b[attr] ? 1 : (a[attr] < b[attr] ? -1 : 0));
break;
default:
throw('Bad attribute');
}
};