We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Array#to_js
1 parent 422e8f6 commit c0be5fdCopy full SHA for c0be5fd
ext/js/lib/js/array.rb
@@ -2,10 +2,8 @@ class Array
2
# Convert Ruby array to JavaScript array
3
def to_js
4
new_array = JS.eval("return []")
5
- self.each do |element|
6
- # NOTE: This method call implicitly convert element to JS object by to_js
7
- new_array.push element
8
- end
+ # NOTE: This method call implicitly convert element to JS object by to_js
+ new_array.push *self
9
new_array
10
end
11
0 commit comments