Class: Array
Instance Method Summary collapse
Instance Method Details
#to_json ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'opal/stdlib/json.rb', line 109 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
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'opal/stdlib/native.rb', line 419 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 |