본문 바로가기

dev/JavaScript

Change the language of tinyMCE (using tinymce-i18n) If you have a paid subscription for tinyMCE, simply changing the language option is all you need to do. The languages available in the paid model are as follows. (link) tinymce.init({ selector: 'textarea', // change this value according to your HTML language: 'ko_KR' }); In this post, we will explore how to change the language when using bundling without a paid subscription. Official Page Guidel..
tinyMCE 언어 변경하기 (tinymce-i18n 사용) tinyMCE를 유료 구독하고 있다면 단순히 language 옵션을 변경해주기만 하면 됩니다. 유료 모델에서 제공하는 언어는 다음과 같습니다. (링크) tinymce.init({ selector: 'textarea', // change this value according to your HTML language: 'ko_KR' }); 본 포스팅에서는 유료 구독을 하지 않고 직접 번들링하여 사용할 때 언어 번경 방법을 살펴보겠습니다. 공식 페이지 가이드라인 먼저 공식 페이지에서 제공하는 가이드라인은 다음과 같습니다. Download the language pack from the Tiny Community Language Packages download page. Set the language option..
debounce와 throttle 개인 프로젝트 중 무의미한 스크롤 이벤트를 줄여야 했습니다. 그 과정에서 debounce, throttle 개념에 대해 알게 되어 정리 차 글로 남깁니다. debounce 맨 마지막으로 호출된 함수만 실행시킵니다. 아래와 같은 형태로 작동합니다. 중간에 함수가 다시 호출되면 타이머를 초기화 하고 delay 만큼 기다린 후 실행합니다. 따라서 최종적으로는 마지막 fn()이 호출된 시점 + delay 후에 함수가 실행됩니다. function debounce(fn, delay) { let timer = null; // timer 은닉을 위해 클로저를 사용 return function () { // 클로저 함수 안에서 this 와 arguments 변수로 디바운싱 함수의 스코프와 변수에 접근 const cont..
JavaScript 안정 정렬 Stable sort란? 정렬 기준에 차이가 없다면 원래 입력에서 주어진 순서를 유지하는 정렬을 말합니다. 만약 두 항목이 같은 값을 가지면 그들의 순서가 정렬된 리스트에 유지됩니다. (values that have the same key keep their original order) Stable sorting algorithms maintain the relative order of records with equal keys. [...] Whenever there are two records (let's say R and S) with the same key, and R appears before S in the original list, then R will always appear before S..
JS 코딩테스트를 위한 코드 스니펫 1. 0~9 까지 숫자 배열 생성 Array.from({length:10}, (val,idx)=>idx) 2. 정수 난수 생성 min
CPS 예외 처리 패턴 CPS에서는 일반적으로 요류를 호출 체인의 다음에서 콜백으로 전달하여 수행된다. Node.js 콜백 규칙에 따르면 오류는 콜백의 첫번째 인수로 전달된다. const fs = require('fs') function readJSON(fileName, callback){ fs.readFile(filename, 'utf8',(err,data)=>{ let parsed; if(err) // 오류 전달 후 현재 함수 종료 // 콜백이 호출되는 즉시 readJSON을 종료하기 위해 return을 사용한다. return callback(err); try{ parsed = JSON.parse(data) }catch(err){ // 에러 catch 후 오류 전달 return callback(err); } callback..
자바스크립트 Execution Context 1 Execution Context 개념 Execution context는 javascript 코드를 실행하기 위해 필요한 환경을 말한다. 자바스크립트 엔진이 코드를 실행하기 위해서는 다음 정보를 알아야 한다. 변수 : 전역변수, 지역변수, 매개변수, 객체 프로퍼티 함수 선언 Scope 정보 this javascript 엔진은 execution context를 객체로써 관리한다. execution context 객체는 위의 정보를 저장하기 위해 아래와 같이 3개의 프로퍼티를 갖는다. 각 프로퍼티에 대한 간단한 설명은 다음과 같다. variable object (VO) : 변수, 매개변수, 함수 선언 정보를 담는다. scope chain : 스코프 정보를 담는다. thisValue : this 바인딩 정보를 ..
화살표 함수와 this 화살표 함수와 this 일반 함수와 화살표 함수의 this는 바인딩할 객체를 결정하는 시점이 다르다. 일반 함수 : 함수 호출 방식에 따라 동적으로 결정 화살표 함수 : 정적으로 결정. 항상 상위 스코프의 this 를 가리킨다 (Lexical this) 다음 예시를 통해 둘의 차이를 알 수 있다. /* ======================== 일반 함수 =========================== */ function Prefixer(prefix) { this.prefix = prefix; } Prefixer.prototype.prefixArray = function (arr) { return arr.map(function (x) { return this.prefix + ' ' + x; // 여..