class myPlugin {
constructor(element, options) {
this.element = element
this.options = Object.assign({}, {
option1: false,
option2: 600
}, options)
}
testMyEvent(){
if (typeof this.options.onEvent === 'function') {
this.options.onEvent(this.element, 123, this.options /* что угодно */);
}
}
}
const plugin = new myPlugin("#element", {
option1: false,
option2: 600,
onEvent: (element, num, opts) => {
console.log(element, num, opts)
}
});
plugin.testMyEvent();
const dataNew = {};
data.forEach(
(item) => dataNew[item.City] ? dataNew[item.City].push(item) : dataNew[item.City] = [item]
);
var() may now be passed in place of multiple arguments to rgb(), rgba(), hsl() and hsla().
//для первого варианта
var arr = str.split('rooms[]=')
var strNew = arr[0] + 'rooms[]=' + [arr[1],arr[2],arr[3]].join(",").replace(/&/g,"")
//для второго варианта
var result = {};
str.forEach(function(item){
var pair = item.split("=");
if(!result.hasOwnProperty(pair[0])){
result[pair[0]] = pair[1]
}
else{
result[pair[0]] += ","+ pair[1]
}
})
var strNew = ['price_max='+result['price_max'], 'price_min='+result['price_min'], 'rooms='+result['rooms[]']].join("&")