var O = function(someValue) { } O.prototype.hello = function(){ return "hhhhhhh"; } var i = new O("chris"); console.log(i.hello()); //this prints out hhhhhhh
function O(){ var self = this; this.name="hello"; this.f=function(){ alert(self.name);//why does "this" refer to the array arr rather than the object? }; this.arr=[]; this.arr["x"]=this.f; } var d=new O(); d.arr["x"]();
var O = function() { this.b = 4; this.c = 8; this.d = this.b + this.c; } var o = new O();
jsEngine.eval("function makeJsObject(nativeObject) { return {nativeObject:nativeObject}; };"); O o = new O(3); Object q = iv.invokeFunction("makeJsObject", o); jsEngine.put("q", q); jsEngine.eval("q.test = function(x) { return this.nativeObject.test(this.nativeObject.mV * x); };"); Object result = iv.invokeMethod(q, "test", 4);
var O = function O() { this.val = 'value'; this.toJSON = function () { return ['VALUE!']; }; }; var o = new O(); var s = JSON.stringify(o); console.log(s); // >> ["VALUE!"]
function O(x,y) { this.x=x; this.y=y; this.method=function() {...} return this; } var o=new O(0,0);
function O() { this.resize = function() {}.bind(this); } var o = new O();
var O = function () {}; O.prototype.fn = function fn () {} var obj = new O();
var m = new O({}) m['a'] = {id:1, foo:'bar'} m['b'] = {id:2, foo:'bar'}
function O() { this.foo = 'foo'; } O.prototype = { bar: 'bar' } var o = new O(); for(var v in o) { console.log(v); // foo bar } Object.getOwnPropertyNames(o).forEach(function(val, idx, array) { console.log("getOwnPropertyNames() " + val); }); Object.keys(o).forEach(function(val, idx, array) { console.log("keys() " + val); });
var O = function(someValue){ this.someValue = someValue; }; O.prototype.hello = function(){ return "hello, " + this.someValue; }; var i = new O("chris"); console.log(i.hello()); // prints hello, chris O.prototype.hello = function() { return 'Hi there '+ this.someValue; } console.log(i.hello()); // prints Hi there chris var test = new O('Sujay') console.log(test.hello()) // prints Hi there Sujay
var O = function(someValue){ this.someValue = someValue; this.hello = function(){ return "hello, " + someValue; } } var i = new O("chris"); console.log(i.hello()); // prints hello, chris i.hello = function() { return 'Hi there '+ this.someValue; } console.log(i.hello()); // prints Hi there chris var test = new O('Sujay') console.log(test.hello()) // this still prints hello, Sujay
O o = new O(); // Create an O on the heap, put a reference to it on the stack x(o); // Pass a copy of the reference into x, the reference still points to O
chunk = new VP(jCas, start, end); } else if(chunkType.equals("O")) { chunk = new O(jCas, start, end); } else { chunk = new Chunk(jCas, start, end);
chunk = new VP(jCas, start, end); } else if(chunkType.equals("O")) { chunk = new O(jCas, start, end); } else { chunk = new Chunk(jCas, start, end);