0
My idea is this, as I have many repeated tasks, I created a Javascript object and access the functions related to it through the .
, for example:
Objeto.funcao(params)
But I need something like jQuery that uses so much $()
as $.()
.
How can I assign a function equivalent to $()
? I tried it this way>
const $ = {
$: function(text) { alert(text) }
f1: function(text) { alert(text) }
f2: function(text) { alert(text) }
}
$('texto padrao') // erro gerado pelo browser dizendo que precisa acessar como objeto
$.f1('texto f1') // retorna alert dizendo 'texto f1'
Set $ as a function (const $ = Function...) and then "hang" F1 functions, F2 in function ($.F1 = Function...). A function is also an object in JS, so you can put penduricalhos in it.
– epx
Thank you Exp, helped me a lot
– João Alves