어떻게 jquery같은 아름다운걸 만들었을까? 라고 생각하면서 잠시 브라우저를 가지고 놀아봤다.
초창기에는 이렇게 만들지 않았을까 ?
//이렇게 $를 정의해버리고
var $ = function(id){ return document.getElementById(id);}
// 이렇게 쓰구
$("jquery_test"); // => <div class="note" id="jquery_test">…</div>
//이게 불편해서
$("jquery_test").style.color = "tomato"
//이렇게 정의하고
HTMLElement.prototype.fontColor = function(color){ this.style.color = color}
// 이렇게 쓰구
$("jquery_test").fontColor("blue");
jquery만든분 존경합니다.