Class: Array
Instance Method Summary collapse
Instance Method Details
#to_json ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'opal/stdlib/json.rb', line 117 def to_json %x{ var result = []; for (var i = 0, length = #{self}.length; i < length; i++) { result.push(#{`self[i]`.to_json}); } return '[' + result.join(', ') + ']'; } end |
#to_n ⇒ Object
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'opal/stdlib/native.rb', line 408 def to_n %x{ var result = []; for (var i = 0, length = self.length; i < length; i++) { var obj = self[i]; if (#{`obj`.respond_to? :to_n}) { result.push(#{`obj`.to_n}); } else { result.push(obj); } } return result; } end |