Web Programming/JavaScript
-
[JavaScript] Object 반복문 사용하기 (for...in)/Key-Value 지정Web Programming/JavaScript 2021. 1. 20. 00:37
for... in Object 형식의 값들을 반복문을 통해 가져오고자 할때 const object = { a: 1, b: 2, c: 3 }; for (const property in object) { console.log(`${property}: ${object[property]}`); } property -> key값 object[property] -> value 값 developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in Key-Value 지정 error 처음에 생각한 방식, happyCount라는 값이 저장되지 않는다. let key = "happyCount"; myArray.push({ key: 'value' ); ..
-
[JavaScript] 소수점 올림, 버림, 반올림Web Programming/JavaScript 2021. 1. 18. 11:53
소수점 올림 console.log(Math.ceil(7.004)); // expected output: 8 출처 developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil Math.ceil() - JavaScript | MDN The Math.ceil() function always rounds a number up to the next largest integer. Note: Math.ceil(null) returns integer 0 and does not give a NaN error. The source for this interactive example is stored in a GitHub reposito..