Just climbed a few mountains, captured a few demons, demons why is there so much of him?

Irregularly updated

Next article

6. FromCharCode () method and deconstruction:

Today I saw a problem in nuggets

let arr = [{ a: 1, i: { b: 2, c: 3, d: 4 } }]; How do I get abcd without I?Copy the code

Learn two ways:

1 >.

// Convert Unicode encoding to a character (105 is I)
      const arr = [{ a: 1.i: { b: 2.c: 3.d: 4}}];const {b,c,d} = arr[0] [String.fromCharCode(105)]; 
      console.log(b,c,d);
Copy the code

2 >.

/ / deconstruction
      let arr = [{ a: 1.i: { b: 2.c: 3.d: 4}}];let [{ a, i: { b, c, d } }] = arr;
      console.log(a, b, c, d);
Copy the code

It was originally recorded at boiling point, but I saw another thought in the comments section that felt more interesting

3 >.

/ / regular
      let arr = [{ a: 1.i: { b: 2.c: 3.d: 4}}];console.log(/"a":(.) /.exec( JSON.stringify(arr))[1]);
Copy the code

Both are masters 🙂

Exec () the exec() method is used to retrieve a match of a regular expression in a string. Returns a matching value if there is one in the string, null otherwise.Copy the code

To be continued…