JavaScript – Passing a Function to a Function

On the example of the usual exporting functions to JS and a section of code on Svelte.

File 1: JS file of exported functions

let time out = null;
export function updateWait(item, updateNote) {

timeout = setTimeout(function () {
}, 1000);

File 2: Svelte

– First we import the function.
– Then the main function, which we will further transfer to the imported function.
– And at the very bottom, we call the imported function and pass parameters there: one of the parameters is the second function.

import {updateWait} from ‘../../assets/js/universal’;

function updateOperation(operation) {
let data = {
‘note’: operation.note

patchFetch(‘update/’, data);

<textarea rows=“2”
on:key down=“{handle}”
on:input=“{()=> updateWait(operation, updateOperation)}”

The site has no goal of self-sustaining, so there are no ads on the site. But if the information was useful to you, you can like the page, leave a comment, or send me a gift for a cup of coffee.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *