Defining the parameter sDataToWrite as var instructs the compiler that you intent to change the data passed in that parameter and you want that changes to persist when you exit the function (aka return the changes to the caller). if you have intention to change the data passed then define it as const or if you do not have any intention to return the changes then simple remove the var definition.