본문 바로가기

JavaScript18

JavaScript call apply bind 살펴보기 call / apply / bind를 왜 알아야 할까? 위 3가지는 자바스크립트에서 함수 호출 방식을 다양하게 제어 할 수 있도록 도와주는 중요한 기능이다. 함수호출 시 자바스크립트의 this를 명시적으로 지정하여 핸들링 할 수 있기때문이다. 여기서 this란? 자바스크립트에서 this값이란 함수를 호출할 때 참조할 객체를 의미한다. 함수 내에서 this를 사용하면 해당 함수를 호출한 객체를 가리킨다. 함수를 다른 방식으로 호출 할 경우 this값이 예기치 않게 변경될 수 있다. 그러한 점을 방지하기 위해 call / apply / bind를 사용하여 this 값을 명시적으로 지정해 줄 수 있다. call 첫번째 인자에 명시할 this객체를 넘기고, 두번째 인자에는 함수 파라미터값을 넘긴다. apply와.. 2023. 5. 10.
TypeScript Compiler 탑레벨 프로퍼티 훝어보기 npm init -y npm i typescript -D npx tsc --init 타입스크립트 생성 complieOnSave - true / false (default false) extends - 상속받아올 부모 패스 설정 // base.json { "compilerOptions": { "strict": true } } // tsconfig.json { "extends": "./base.json", ... } // true일 경우 compiler error 발생 const a: number = undefined; (X) const a: number = 123; (O) { "extends": "@tsconfig/deno/tsconfig.json", ... } files - 상대 or 절대경로의 리스트 .. 2023. 5. 9.
디바이스 정보를 가져오는 Native Module 만들어보기 Android // DeviceInfoModule.java package com.nativemodule; import androidx.annotation.NonNull; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; // 추상 클래스 ReactContextBaseJavaModule 상속 public class DeviceInfoModule extends ReactContextBaseJa.. 2023. 4. 28.
React-Native NativeModules 네이티브 모듈 만들기 https://reactnative.dev/docs/native-modules-android Android Native Modules · React Native Welcome to Native Modules for Android. Please start by reading the Native Modules Intro for an intro to what native modules are. reactnative.dev https://reactnative.dev/docs/native-modules-ios iOS Native Modules · React Native Welcome to Native Modules for iOS. Please start by reading the Native Modules Int.. 2023. 4. 26.