<div>
<div class="div2"></div>
<div class="div2"></div>
<div class="div2"></div>
</div>
function el(e) {
var target = e.target
, arr = target.parentNode.children
, len = arr.length
, i = 0
, elementIndex = null
;
for(; i<len; i++){
if(arr[i] === target){
elementIndex = i;
break;
}
}
console.log('elementIndex: ', elementIndex);
}
window.addEventListener("click", el);
moment.min(["25.02.2010 17:00", "23.08.2011 18:47", "03.12.2009 11:08", "15.02.2010 17:06"])
moment.max(["25.02.2010 17:00", "23.08.2011 18:47", "03.12.2009 11:08", "15.02.2010 17:06"])
Sometimes, you want all the goodness of moment#from but you don't want to have to create two moments, you just want to display a length of time.
moment.duration(1, "minutes").humanize(); // a minute
moment.duration(2, "minutes").humanize(); // 2 minutes
moment.duration(24, "hours").humanize(); // a day
moment.duration(22, "hours") + "hours"
В остальных языках тоже так? функции можно записывать в переменные, возвращать из функций, передавать как параметр в функцию, без вызова?
var u = new URL('https://toster.ru/q/368178')
console.log('Host is:", u.host);
hash: ""
host: "toster.ru"
hostname: "toster.ru"
href: "https://toster.ru/q/368178"
origin: "https://toster.ru"
password: ""
pathname: "/q/368178"
port: ""
protocol: "https:"
search: ""
searchParams: ""
username: ""
console.log('Current page host is:", location.host);