Answered by : powerful-puma-s9j8d8qc4sn8
function delay(time) { return new Promise(resolve => setTimeout(resolve, time));
}
delay(1000).then(() => console.log('ran after 1 second1 passed'));
Source : https://masteringjs.io/tutorials/fundamentals/wait-1-second-then | Last Update : Mon, 01 Nov 21
Answered by : fantastic-fly-tycec05x49b8
function myFunction(){ console.log('hi')
}
myFunction()
Source : | Last Update : Mon, 16 Mar 20
Answered by : relieved-rattlesnake-2afoirzowtbo
function factorial(n) { if (n == 0) { return 1; } else { return factorial(n - 1) * n; }
}
Source : http://eloquentjs.ir/00_intro.html | Last Update : Sun, 18 Jul 21
Answered by : nerdy-exploit
function doSomething()
{ var x; x = 10; y = 20; alert('x = ' + x); alert('y = ' + y);
}
Source : http://blog.niftysnippets.org/2008/03/horror-of-implicit-globals.html | Last Update : Wed, 09 Nov 22
Answered by : ved
function world(params){ //Code to be executed when the function is called.
}
world()
//Explaination
//'world' in the function is the name of the function.
//There are brackets after function name. Those are use to push parameters
//The forth line Calls the function named 'world'
Source : | Last Update : Sun, 03 Jul 22
Answered by : danielnachumdev
#pip install danielutils
from danielutils import overload
class Foo: def __init__(self): pass #'None' to skip @overload(None, int) def __add__(self, other): return 1 @overload(None, str) def __add__(self, other): return 2
@overlaod(str,[int,float])
def bar(name,age): return 3
@overload(str,str)
def bar(name,color): return 4
if __name__ == '__main__': print(Foo()+5) #-> 1 print(Foo()+"s") #-> 2 print(bar("jake",5)) #-> 3 print(bar("jake",5.5)) #-> 3 print(bar("jake","blue")) #-> 4
Source : https://github.com/danielnachumdev/danielutils/blob/e8c72fea9c13a43267627268ba29721de0d29f99/danielutils/Decorators.py#L143 | Last Update : Sat, 01 Oct 22
Answered by : cloudy-chamois-7p7jp2tuzyh7
function say(message) { console.log(message);
}
let result = say('Hello');
console.log('Result:', result);
Code language: JavaScript (javascript)
Source : https://www.javascripttutorial.net/javascript-function/ | Last Update : Tue, 09 Aug 22
Answered by : sanderson
function functionName(parameter1, parameter2, parameter3) { body code goes here
}
Source : https://my.learn.co/courses/380/pages/review-functions?module_item_id=41812 | Last Update : Thu, 31 Mar 22
Answered by : marcogt
funcion name_of_funtion(){
}
Source : | Last Update : Tue, 11 May 21
Answered by : samer-saeid
def function_name(parameters): """docstring""" statement(s)
Source : | Last Update : Thu, 02 Jun 22