Skip to content

Tag: ecmascript-6

Add elements inside Array conditionally in JavaScript

When I try to merge two objects using the spread operator conditionally, it works when the condition is true or false: When I try to use the same logic with Arrays, it only works when the condition is true: If the condition is false an error is thrown: Why is the behaviour different between Array and Object? …