모든 Object Prototype 을 갖는다. var a = {}; //Firefox 3.6 and Chrome 5 Object.getPrototypeOf(a); //[object Object] //Firefox 3.6, Chrome 5 and Safari 4 a.__proto__; //[object Object] //all browsers a.constructor.prototype; //[object Object] Prototype 상속 받아 사용 할수 있다 //unusual case and does not work in IE var a = {}; a.__proto__ = Array.prototype; a.length; //0 //function will never be a constructor bu..
1. By Direct Assignment var myApp = {} myApp.id = 0; myApp.next = function() { return myApp.id++; } myApp.reset = function() { myApp.id = 0; } window.console && console.log( myApp.next(), myApp.next(), myApp.reset(), myApp.next() ); //0, 1, undefined, 0 var myApp = {} myApp.id = 0; myApp.next = function() { return this.id++; } myApp.reset = function() { this.id = 0; } myApp.next(); //0 myApp.nex..
* Javascript RegEx Api The RegExp object RegExp 글로벌 오브젝트는 3가지 사용을 제시한다. var a = new RegExp("\\b[\\w]{4}\\b","g"); //match all four letter words //same as... a = /\b\w{4}\b/g; a.constructor //RegExp() "(penalty)Lampard, Frank(1-0)".match(/\b([\w]+),\s?([\w]+)/g); RegExp.leftContext //"(penalty)" RegExp.rightContext //"(1-0)" RegExp.$1 //"Lampard" RegExp.$2 //"Frank" var a = /\b[a-z]{10,}\b/i; //m..
Invoke a property alert(this); //window var a = { b : function(){ return this; } }; a.b(); //a; a['b'](); //a; var c = {}; c.d = a.b; c.d() //c Invoke a variable var a = { b : function() { return this; } }; var foo = a.b; foo() // window var a = { b: function(){ var c = function() { return this; } return c(); } }; a.b(); //window var a = { b : function() { return (function() { return this;})() }..
String.prototype.split(separator, limit) "85@@86@@53".split("@@"); //['85', '86', '53']; "bannana".split(); //["banana"]; "원,투,쓰리".split(",",2); // ["원","투"] Array.prototype.join(separator) 배열을 스트링으로 변환 합니다. ["slugs","snails","puppy dog's tails"].join(' and '); //"slugs and snails and puppy dog's tails" ['Giants', 4, 'Rangers', 1].join(' '); //"Giants 4 Rangers 1" [1962,1989,2002,2010].join(); /..