Javascript examples for Object:prototype
Set array value from a function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {// ww w. j a v a2s . co m function Foo(arr) { this.arr = arr; } var f = new Foo(['a', 'b', 'c', 'd']); Foo.prototype.setValue = function(index, v) { this.arr[index] = v; } idx = 0; f.setValue(idx, "Z"); console.log(f); }); </script> </head> <body> </body> </html>