3

Working with Lightning Components, I encountered the following problem. When I try to init some var within my controller method using the name of "arguments" my LC component stops loading.

onSearchButtonClick: function (component, event, helper) {
        let fromTimeValue = component.find('from-time').get('v.value');
        let toTimeValue = component.find('to-time').get('v.value');
        let arguments = {
            'fromTime': fromTimeValue,
            'toTime': toTimeValue
        };
        helper.loadDataWithParams(component, arguments, event);
}

However, when I change the name of this var to any other one it works. I suspect that the "arguments" keyword is reserved, but unfortunately, I couldn't get detailed information about the list of reserved words in the LC. Maybe someone can clarify this problem? Thanks)

2 Answers 2

3

I'm not sure about what the problem is exactly, since it seems that browsers let you override the native arguments object, but I'm guessing that a linter is raising a problem because doing so could cause bugs in the code.

To answer your question, these are the reserved keywords in javascript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords

Here's a reference to the arguments object if you want more information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments

3

Eventually, I have found out what was a problem.

ES5 §15.1.1

Value Properties of the Global Object (NaN, Infinity, undefined), as well as strict mode restricted identifiers eval and arguments are considered to be restricted names in JavaScript. Defining them to mean something else can have unintended consequences and confuse others reading the code.

The full table of JavaScript Reserved Words is available below:

JavaScript Reserved Words

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.