분류 전체보기
-
image 색깔 바꾸기컴퓨터/HTML & CSS 2020. 3. 27. 11:46
https://codepen.io/sosuke/pen/Pjoqqp CSS filter generator to convert from black to target hex color ... codepen.io 'use strict'; class Color { constructor(r, g, b) { this.set(r, g, b); } toString() { return `rgb(${Math.round(this.r)}, ${Math.round(this.g)}, ${Math.round(this.b)})`; } set(r, g, b) { this.r = this.clamp(r); this.g = this.clamp(g); this.b = this.clamp(b); } hueRotate(angle = 0) { a..
-
How to make an exact copy of an element?컴퓨터/JavaScript_typescript 2020. 3. 25. 09:58
* deep copy // Node.cloneNode() var elem = document.querySelector("#node1"); // optional boolean argument, deep // true -> the child elements (including text nodes) are copied, too var copy = elem.cloneNode(true); // modify the id copy.id = 'node2'; //insert into the DOM before the original elem.parentNode.insertBefore(copy, elem); * shallow copy // cloneNode(false) -> no child nodes are copied ..
-
[JavaScript] Object.freeze : 객체를 불변하게 만들기, const(reference 규제)와의 차이점(freeze: 값을 규제)컴퓨터/JavaScript_typescript 2020. 2. 11. 14:07
* object는 쉽게 바뀔 수 있다. var o1 = {name:'kim'. score[1,2]}; o1.name = 'lee'; console.log(o1); // o1이라는 원본을 바꿔버린다 {name:'lee', score[1,2]} * Object.freeze 가변이면 안되는 데이터를 규제할 수 있다. var o1 = {name:'kim'. score[1,2]}; Object.freeze(o1) o1.name = 'lee'; console.log(o1); // {name:'kim', score[1,2]} freeze를 풀고 싶다면 복사해야 한다. * free한 객체 안에 다른 객체가 있다면 그것은 freeze하지 못한다. var o1 = {name:'kim'. score[1,2]}; Object..
-
[weird JavaScript] type coercion, ==와 > < operator, ++, --도 type coercion 사용컴퓨터/JavaScript_typescript 2020. 2. 11. 13:57
* type coercion automatically convert a value from one data type to another when using some sort of operator with it var html1 = 2+" Hello, world." // "2 Hello, world" * ==(equals) vs ===(strict equals) Strict equals (===) check that items have both the same value and the same data type. ex) '42' === 42 : false Regular equals (==) uses type coercion to compare the values of the items, ignoring t..
-
-
$(function(){}) vs window.onload컴퓨터/jQuery 2020. 2. 9. 14:03
1) $(function() {}) $(document).ready(function(){}); 페이지가 로딩되었을 때 일어나길 바라는 이벤트들이 작성된다. 리소스와 상관없이 DOM만 생성되어도 호출된다. 예를 들어 이미지 같은 리소스를 요구하는 페이지일 경우 이미지 로딩 완료 상관없이 진행 2) window.onload = function() {}; 리소스 호출도 완료되었을 경우 실행 출처 : https://recoveryman.tistory.com/104