This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| @author http://www.shamasis.net/2009/09/fast-algorithm-to-find-unique-items-in-javascript-array/ | |
| */ | |
| // prototype | |
| Array.prototype.unique = function() { | |
| var o = {}, i, r = []; | |
| var l = this.length; | |
| for (i = 0; i < l; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- 세션을 만들어줄 서버에서 P3P 헤더를 설정 --> | |
| <?php | |
| header('P3P: CP="CAO PSA OUR"'); | |
| ?> | |
| <!-- 세션을 가지고 오는 클라이언트 요청--> | |
| <script> | |
| $.ajax({ | |
| url:'cross domain session create url', | |
| type:'post', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var totalCount; | |
| var currentPageNum; | |
| var shownRowNum; | |
| for(var i=0, len=data.length; i<len; i++){ | |
| var index = (Number(totalCount)-(i+(currentPageNum-1)*shownRowNum)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| function test(){ | |
| if(true){ | |
| return false; | |
| } | |
| } | |
| </script> | |
| <!-- 페이지에 return false;가 출력됨 --> | |
| <a href='javascript:test();'>테스트</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // JavaScript syntax to set a default value | |
| var text = someString || "default text"; | |
| var text2 = someString || someString2 || "default text2"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var frozenObject = { | |
| value1 : 1, | |
| value2 : 2 | |
| }; | |
| Object.freeze(frozenObject); | |
| console.log(Object.isFrozen(frozenObject)); // true | |
| // 삭제 불가 | |
| delete frozenObject.value1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sealedObject = { | |
| value1 : 1, | |
| value2 : 2 | |
| }; | |
| Object.seal(sealedObject); | |
| console.log(Object.isSealed(sealedObject)); // true | |
| // 삭제 불가 | |
| delete sealedObject.value1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var preventExtensionObject = { | |
| value1 : 1, | |
| value2 : 2 | |
| }; | |
| Object.preventExtensions(preventExtensionObject); | |
| console.log(Object.isExtensible(preventExtensionObject)); // false | |
| // 삭제 가능 | |
| delete preventExtensionObject.value1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function deepFreeze(obj){ | |
| if (!Object.isFrozen(obj)){ | |
| Object.freeze(obj); | |
| } | |
| for (var key in obj) { | |
| if ({}.hasOwnProperty.call(obj, key) || !(typeof obj[key] === 'function' || typeof obj[key] === 'object' && !!obj[key])) { | |
| continue; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function jsonp(url, callback) { | |
| var callbackName = 'jsonp_' + Math.round(100000 * Math.random()); | |
| window[callbackName] = function(data) { | |
| delete window[callbackName]; | |
| document.body.removeChild(script); | |
| callback(data); | |
| }; | |
| var script = document.createElement('script'); | |
| script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName; | |
| document.body.appendChild(script); |