I want to use a function in javascript that has many parameters that likely have long names. I want it to look something like this:
functionName( parameter1,
parameter2,
parameter3 );
so far I've tried doing the following to no avail:
functionName( parameter1, \
parameter2, \
parameter3 );
I understand that "\" is supposed to have things continue on to the next line. Am I missing something?
When you call a function in JavaScript, you can pass in any number of arguments, regardless of what the function declaration specifies. There is no function parameter limit. In the above function, if we pass any number of arguments, the result is always the same because it will take the first two parameters only.
There are two ways to break JavaScript code into several lines: We can use the newline escape character i.e “\n”. if we are working on the js file or not rendering the code to the html page. We can use the <br> tag.
There are three ways to create strings that span multiple lines: By using template literals. By using the + operator – the JavaScript concatenation operator. By using the \ operator – the JavaScript backslash operator and escape character.
using a multiline function: a function whose defining rule consists of. several pieces.
You do not need any special character to span lines. Your original is fine:
functionName(parameter1,
parameter2,
parameter3) {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With