2021.04.15

김승우·2021년 4월 15일
0

TIL

목록 보기
47/68

2021.04.15

오브젝트 속성명을 Number로하기

: https://stackoverflow.com/questions/16908476/object-property-name-as-number

isNaN

  isNaN(null) // false
  isNaN(0) // false
  isNaN() // true

임시 데이터 return 함수

	function list() {
		console.log("[list]");
	  
		const data = [
			{
				id: "order",
				title: "카드1",
				className: "w100",
				sort: 1,
				template: "order-template",
				position: {},
			},
			{
				id: "claim",
				title: "카드2",
				className: "w50",
				sort: 2,
				position: {},
				template: "claim-template",
				data: {
					text: "abc",
					url: "",
				}
			},
			{
				id: "card-3",
				title: "카드3",
				className: "w25",
				sort: 3,
				position: {},
			},
			{
				id: "card-4",
				title: "카드4",
				className: "w25",
				sort: 4,
				position: {},
			},
		];
	  
		const layoutData = localStorage.getItem("layoutData");
	  
		if (typeof layoutData === "string") {
			try {
				console.log(layoutData);
				return Promise.resolve(JSON.parse(layoutData));
			} catch (error) {
				return Promise.resolve(data);
			}
		} else {
			return Promise.resolve(data);
		}
	}
profile
사람들에게 좋은 경험을 선사하고 싶은 주니어 프론트엔드 개발자

0개의 댓글