let [a, b, ,c] = [1, 2, 3, 4]
let {a, b, c} = {a:1, b:2, c:3}
object ColorHandler {
/**
* Color sample: 556A74
*/
fun getColorName(color: String): String {
if (color in names.keys)
return names[color]!!
val r = color.slice(0..1).toInt(16)
val g = color.slice(2..3).toInt(16)
val b = color.slice(4..5).toInt(16)
var currentMin: Pair<Int, String>? = null
var range: Int
names.forEach { (colorValue, name) ->
range = (
(r - colorValue.slice(0..1).toInt(16)).pow() +
(g - colorValue.slice(2..3).toInt(16)).pow() +
(b - colorValue.slice(4..5).toInt(16)).pow()
)
when {
currentMin == null -> {
currentMin = range to name
}
currentMin!!.first > range -> {
currentMin = range to name
}
currentMin!!.first < range -> {
return@forEach
}
}
}
return currentMin!!.second
}
}
const newArr = arr.map(function(n) {
return [ ...n, ...Array(this - n.length).fill('') ];
}, Math.max(...arr.map(n => n.length)));
const max = arr.reduce((max, { length: n }) => max > n ? max : n, 0);
arr.forEach(n => n.push(...Array(max - n.length).fill('')));
parseInt('1!!!') // 1
+'1!!!' // NaN
parseInt('') // NaN
+'' // 0
parseInt('3.14159') // 3
+'3.14159' // 3.14159
parseInt('0b1000101') // 0
+'0b1000101' // 69
parseInt('0o273') // 0
+'0o273' // 187
parseInt({ valueOf: () => 666 }) // NaN
+({ valueOf: () => 666 }) // 666
parseInt('1000000000', 2) // 512
+'1000000000' // 1000000000
parseInt('99', 8) // NaN
+'99' // 99
parseInt('DEAD', 16) // 57005
+'DEAD' // NaN
return num * fac(num - 1)
выполняется умножение на undefined.db.Clients.find({}).forEach(el => {
db.Clients.updateOne({ _id: el._id }, { $set: { phone: [el.phone] }})
})
if (APP?.config?.env?.stage === 'dev')
function flags($value) {
if (!in_array($value, [0, 1, 2, 3, 6, 7, 8, 9])) {
return false;
}
$result = [];
if (in_array($value, [1, 3, 7, 9])) {
$result[] = 'a';
}
if (in_array($value, [2, 3, 8, 9])) {
$result[] = 'b';
}
if (in_array($value, [6, 7, 8, 9])) {
$result[] = 'c';
}
return $result;
}