Is 'div' a Parameter or an Argument in JavaScript's document.createElement Method?

3 replies
Hello Fellow Warriors,

In JavaScript's document.createElement('div'), is 'div' a parameter or an argument? While checking https://developer.mozilla.org/en-US/.../createElement, I noticed the section titled "Parameters."

However, upon further research, I found other resources referring to it as "arguments." In the context of function calls in JavaScript, 'div' is an argument. You pass this string to specify the type of element you want to create. It is not considered a parameter when you are calling the createElement method. For instance, in document.createElement('div'), 'div' is the argument you provide to create a <div> element.

Thanks a lot.
#argument #div #documentcreateelement #javascript #method #parameter
  • Profile picture of the author savidge4
    to be honest i dont consider div to be either a Parameter or an Argument, its simply a division element that divides the html tag.

    Yeah you can alter the tag... but you are then introducing "decorateDiv(div)" or the like, and its really not the same thing

    A div is just that, a div... even in the case of a defined decorate div... its still a div
    Signature
    Success is an ACT not an idea
    {{ DiscussionBoard.errors[11789904].message }}
  • Profile picture of the author aronprins
    Hey magiclouie !

    In JavaScript's `document.createElement('div')`, 'div' is actually an argument, not a parameter.

    When calling the `createElement` method, 'div' is the value that you are passing as an argument to specify the type of element you want to create (in this case, a `<div>` element).

    Parameters are placeholders defined in the function signature, while arguments are the actual values passed to the function when it is called. So in this context, 'div' is the argument you provide to the `createElement` method.

    Hope this helps!
    Cheers,
    Aron
    {{ DiscussionBoard.errors[11790123].message }}
    • Profile picture of the author Abdullahcpa
      In other languages there is also a case like this, for example a class object can be an object and also a parameter to another object, so if I'm not wrong you simply need to see the context and different elements can take on different roles, that is why modern programming is so powerfull and versatile
      {{ DiscussionBoard.errors[11790956].message }}
  • Profile picture of the author Meshii Mahi
    In JavaScript, `div` is an argument when passed to the `document.createElement` method.

    Here's the breakdown:
    - **Parameter**: This is a variable in the declaration of the function. In the case of `document.createElement`, the parameter is the element type to create.
    - **Argument**: This is the actual value passed to the function when it is called. When you use `document.createElement('div')`, the string `'div'` is the argument.

    Example:
    ```javascript
    // Calling the method with 'div' as an argument
    let myDiv = document.createElement('div');
    ```

    In this case, `'div'` is the argument provided to the `document.createElement` method.
    {{ DiscussionBoard.errors[11796163].message }}

Trending Topics