Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Review Suggested Edit

You can't approve or reject suggested edits because you haven't yet earned the Edit Posts ability.

Approved.
This suggested edit was approved and applied to the post over 2 years ago by hkotsubo‭.

69 / 255
  • Given the [link where the code comes from](https://github.com/davidjbradshaw/iframe-resizer#usage) (based on your [other question](https://software.codidact.com/posts/286403)), this is just a, let's say, "free-form/pseudo-code/documentation example".
  • It's not a valid JavaScript code. It's more like a free-format "syntax" intended to provide a general documentation about what parameters are expected for that function.
  • It's not uncommon to see many documentation pages that uses such format (not only for JavaScript, BTW). For example, [many Unix/Linux commands](https://man7.org/linux/man-pages/man1/ls.1.html) adopt a similar style in their manual pages.
  • Some documents use brackets to indicate an optional parameter, but I'm not sure if that's the convention used in iFrame Resizer's doc, so read it carefully to see if that's the case.
  • Some others also use `||` to indicate that a parameter can have different values and/or different types.
  • And that's the confusing part, I guess. As that "code" is not actually valid JavaScript code (but only a "free-format-style" documentation example), the brackets does not necessarily mean that it's an array, and the `||` is not the logical OR operator.
  • Basically, `iFrameResize( [{options}], [css selector] || [iframe] )` is just saying (documenting) that `iFrameResize` can take two arguments, and tells us a little information about them.
  • The first one is `options`, which is an object (I'm guessing because it's between `{}`, and given the example in the same documentation - `iFrameResize({ log: true }, '#myIframe')` - I guess I'm right). But what kind of object? What data should it have, and what its purpose? Well, you should take a look at the [documentation](http://davidjbradshaw.github.io/iframe-resizer/), it has a very detailed description of each possible option value.
  • The second argument is `[css selector] || [iframe]`, which means that it can be either a CSS selector (AKA a string, such as `'#myIframe'`, that corresponds to the iframe element) or an iframe element (for instance, an element you've got from a call to `document.querySelector`).
  • ---
  • And that's it. There's nothing special about the `options` object, and its purpose and usage is defined by whatever the `iFrameResize` function expects. I suggest you to read the docs to see all the use cases. But regarding JavaScript, it's just a simple ("normal") object, just like any other one.
  • Given the [link where the code comes from](https://github.com/davidjbradshaw/iframe-resizer#usage) (based on your [other question](https://software.codidact.com/posts/286403)), this is just a, let's say, "free-form/pseudo-code/documentation example".
  • It's not a valid JavaScript code. It's more like a free-format "syntax" intended to provide a general documentation about what parameters are expected for that function.
  • It's not uncommon to see many documentation pages that uses such format (not only for JavaScript, BTW). For example, [many Unix/Linux commands](https://man7.org/linux/man-pages/man1/ls.1.html) adopt a similar style in their manual pages.
  • Some documents use brackets to indicate an optional parameter, but I'm not sure if that's the convention used in iFrame Resizer's doc, so read it carefully to see if that's the case.
  • Some others also use `||` to indicate that a parameter can have different values and/or different types.
  • And that's the confusing part, I guess. As that "code" is not actually valid JavaScript code (but only a "free-format-style" documentation example), the brackets does not necessarily mean that it's an array, and the `||` is not the logical OR operator.
  • <hr>
  • That said,
  • Basically, `iFrameResize( [{options}], [css selector] || [iframe] )` is just saying (documenting) that `iFrameResize` can take two arguments, and tells us a little information about them.
  • The first one is `options`, which is an object (I'm guessing because it's between `{}`, and given the example in the same documentation - `iFrameResize({ log: true }, '#myIframe')` - I guess I'm right). But what kind of object? What data should it have, and what its purpose? Well, you should take a look at the [documentation](http://davidjbradshaw.github.io/iframe-resizer/), it has a very detailed description of each possible option value.
  • The second argument is `[css selector] || [iframe]`, which means that it can be either a CSS selector (AKA a string, such as `'#myIframe'`, that corresponds to the iframe element) or an iframe element (for instance, an element you've got from a call to `document.querySelector`).
  • ---
  • And that's it. There's nothing special about the `options` object, and its purpose and usage is defined by whatever the `iFrameResize` function expects. I suggest you to read the docs to see all the use cases. But regarding JavaScript, it's just a simple ("normal") object, just like any other one.

Suggested over 2 years ago by deleted user