NODE.JS + NEST.JS 교과서
·
스터디/NODE.JS+NEST.JS 교과서
2.1 REPL 사용하기자바스크립트는 스크립트 언어이므로 미리 컴파일하지 않아도 즉석에서 코드 실행 가능브라우저 콘솔 탭에서 자바스크립트 코드 입력과 마찬가지로 노드도 비슷한 콘솔을 제공하는데, 입력한 코드를 읽고(Read), 해석하고(Eval), 결과물을 반환하고 (Print), 종료할 때까지 반복(Loop)한다고 해서 REPL(Read Eval Print Loop)이라고 합니다. $ nodeWelcome to Node.js v25.5.0.Type ".help" for more information. 프롬프트가 > 모양으로 바뀌었다면 자바스크립트 코드 입력 가능함. > const str = 'Hello world, hello node';undefined> console.log(str);Hello wo..
121. Best Time to Buy and Sell Stock ✨
·
LeetCode/Array
🎉 문제You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.Example 1: Input: prices = [7,1,5,3,6,4] Output: 5 Expl..
Vue 3 컴포저블 vs Vue 2 믹스인 비교
·
Frontend/Vue.js
개념 이해✔ Vue 2 믹스인 (Mixin)믹스인은 여러 컴포넌트에서 재사용할 수 있는 옵션 객체입니다. 컴포넌트에 믹스인을 등록하면 해당 믹스인의 옵션들이 컴포넌트의 옵션과 병합됩니다.✔ Vue 3 컴포저블 (Composable)컴포저블은 Composition API를 사용하여 상태와 로직을 캡슐화한 함수입니다. setup() 함수 내에서 호출하여 사용합니다.예제 코드 비교 예제: 사용자 인증 로직 구현 Vue 2 믹스인 방식// authMixin.jsexport const authMixin = { data() { return { user: null, isAuthenticated: false, isLoading: false } }, methods: { ..
88. Merge Sorted Array
·
LeetCode/Array
Merge Sorted ArrayYou are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this,..
27. Remove Element
·
LeetCode
문제 링크:https://leetcode.com/problems/remove-element/ 풀이방법: 배열을 순회하면서 val값과 일치하지 않는 item은 위치를 변경해 준다. cnt는 0부터 시작하고 위치를 변경한 이후에 cnt 카운트를 +1씩 증가 시켜 준다. var removeElement = function(nums, val) { let cnt = 0; // val값과 값이 일치하는 않으면 위치를 변경한다. for (let i=0; i
[LeetCode][JS] 26. Remove Duplicates from Sorted Array
·
LeetCode
🚕 문제https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/ 🚕 풀이 방법/** * @param {number[]} nums * @return {number} */var removeDuplicates = function(nums) { if (nums.length === 0) return 0; let write = 1; // 첫 번째 원소는 항상 고유 for (let read = 1; read