본문 바로가기

프론트기술/JavaScript7

45 useful javascript tips 1 – Don’t forget var keyword when assigning a variable’s value for the first time.Assignment to an undeclared variable automatically results in a global variable being created. Avoid global variables.2 – use === instead of ==The == (or !=) operator performs an automatic type conversion if needed. The === (or !==) operator will not perform any conversion. It compares the value and the type, which.. 2015. 3. 30.
Javascript 옵저버 패턴 var Users = { list: [], listeners: {}, add: function(name) { this.list.push({name: name}); this.dispatch("user-added"); }, on: function(eventName, listener) { if(!this.listeners[eventName]) this.listeners[eventName] = []; this.listeners[eventName].push(listener); }, dispatch: function(eventName) { if(this.listeners[eventName]) { for(var i=0; i 2014. 11. 18.
javascript 이미지 크기 불러오기 비동기로 이미지 불러오는 소스 $j("").attr("src", thumbnailUrl).load(function() {console.log(this.width);console.log(this.height);}); http://stackoverflow.com/questions/318630/get-real-image-width-and-height-with-javascript-in-safari-chrome 2014. 11. 18.
Json - Object 간 변환 JSON-> Object JSON.parse(posStr); Object -> JSON JSON.stringify( info ) 2013. 5. 28.
JQuery 객체에 메서드 추가하기 JQuery 객체에 메서드를 추가하는 방법 1. 사용자 js에 추가 (function($, undefined) { $.fn.extend({ func: (function( orig ) { alert(orig); }) }); })(jQuery); 2. 사용하기 $('#portlet-area').func('hello'); 2013. 4. 11.
JSON Object 와 String 간 변환 참고 : http://www.json.org/js.html 참고2 : http://msdn.microsoft.com/ko-kr/library/cc836459(v=vs.94).aspx 2013. 1. 5.