Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/opal/json.rb

Instance Method Summary collapse

Instance Method Details

#to_jsonObject



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/opal/json.rb', line 106

def to_json
  %x{
    var result = [];

    for (var i = 0, length = this.length; i < length; i++) {
      result.push(#{`this[i]`.to_json});
    }

    return '[' + result.join(', ') + ']';
  }
end