JavaScript allows passing functions as arguments to other functions, which are then invoked inside the other function to notify completion or pass returned data, known as callbacks. Ruby similarly supports passing blocks or procs to methods that are then yielded to or invoked within the method to enable asynchronous behavior or passing data between functions.