CodeQL documentation

Ignoring result from pure array method

ID: js/ignore-array-result
Kind: problem
Security severity: 
Severity: warning
Precision: high
   - maintainability
   - correctness
Query suites:
   - javascript-security-and-quality.qls

Click to see the query in the CodeQL repository

The concat, join and slice methods are pure and do not modify any of the inputs or the array the method is called on. It is therefore generally an error to ignore the return value from a call to one of these methods.


Use the returned value from the calls to concat, join or slice.


A function extend is defined in the following example. The function uses the concat method to add elements to the arr array. However, the extend function has no effect as the return value from concat is ignored:

var arr = [1,2,3];

function extend(others) {

Assigning the returned value from the call to concat to the arr variable fixes the error:

var arr = [1,2,3];

function extend(others) {
	arr = arr.concat(others);


  • © GitHub, Inc.
  • Terms
  • Privacy