Javascript – Using JS array splice in one line and two lines got different result
Code 1: let targetArr = ["hello", "world", "my", "name"]; let errnewArr = Array.from(targetArr).splice(2, 1); console.log("errnewArr array : "+errnewArr.length); Code 2: targetArr = ["hello", "world", "my", "name"]; let newArr = Array.from(targetArr); newArr.splice(2, 1); console.log("new array : "+newArr.length); As you can see…