Skip to content

Add JS::Object#apply method to call JS function without receiver #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

kateinoigakukun
Copy link
Member

This method is similar to JS::Object#call, but it is used to call a function that is not a method of an object.

floor = JS.global[:Math][:floor]
floor.apply(3.14) # => 3
JS.global[:Promise].new do |resolve, reject|
  resolve.apply(42)
end.await # => 42

This method is similar to `JS::Object#call`, but it is used to call a
function that is not a method of an object.

```ruby
floor = JS.global[:Math][:floor]
floor.apply(3.14) # => 3
JS.global[:Promise].new do |resolve, reject|
  resolve.apply(42)
end.await # => 42
```
@kateinoigakukun kateinoigakukun marked this pull request as ready for review March 16, 2024 09:37
@kateinoigakukun kateinoigakukun merged commit aee363b into main Mar 16, 2024
@kateinoigakukun kateinoigakukun deleted the katei/js-object-apply branch March 16, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant