JQuery allows to call the function only once using the method one():
let func = function() {_x000D_
console.log('Calling just once!');_x000D_
}_x000D_
_x000D_
let elem = $('#example');_x000D_
_x000D_
elem.one('click', func);
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>_x000D_
<div>_x000D_
<p>Function that can be called only once</p>_x000D_
<button id="example" >JQuery one()</button>_x000D_
</div>
_x000D_
Implementation using JQuery method on():
let func = function(e) {_x000D_
console.log('Calling just once!');_x000D_
$(e.target).off(e.type, func)_x000D_
}_x000D_
_x000D_
let elem = $('#example');_x000D_
_x000D_
elem.on('click', func);
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>_x000D_
<div>_x000D_
<p>Function that can be called only once</p>_x000D_
<button id="example" >JQuery on()</button>_x000D_
</div>
_x000D_
Implementation using native JS:
let func = function(e) {_x000D_
console.log('Calling just once!');_x000D_
e.target.removeEventListener(e.type, func);_x000D_
}_x000D_
_x000D_
let elem = document.getElementById('example');_x000D_
_x000D_
elem.addEventListener('click', func);
_x000D_
<div>_x000D_
<p>Functions that can be called only once</p>_x000D_
<button id="example" >ECMAScript addEventListener</button>_x000D_
</div>
_x000D_