Skip to content

Commit

Permalink
object and buili in
Browse files Browse the repository at this point in the history
  • Loading branch information
yuichimukai committed Apr 15, 2021
1 parent 959d9e3 commit 02faf25
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ const array = [1, 5, 10, 15, 20];
// console.log(filterEven(array));
console.log(array.filter(isEven));

const obj = {
a: 1,
b: 2,
c: 3,
};

for (const key in obj) {
const value = obj[key];
console.log(`key:${key}, value:${value}`);
}

for (const value of array) {
console.log(value);
}
Expand Down Expand Up @@ -123,3 +112,20 @@ const object1 = { key: undefined };
if (object1.hasOwnProperty("key")) {
console.log("'object1'は'key'プロパティを持っている");
}

const objee = {
a: {
b: "objのaプロパティのbプロパティ",
},
};

console.log(objee?.a?.b);

const shallowClone = (obj) => {
return Object.assign({}, obj);
};

const obj = { a: "a" };
const cloneObj = shallowClone(obj);
console.log(cloneObj);
console.log(obj === cloneObj);

0 comments on commit 02faf25

Please sign in to comment.