Academic query on the scripting approach taken (javascripts)

Hi Sean

I've noticed that the scripting mostly uses var = function and init approach.

Because I'm self-taught from years back, I've never used this approach. So I've been researching it online.

The var function approach seems to result in single use functions, whereas calling a function fname(params){} allows for more flexibility in multi-purposing the script.

I'm finding that I'm repurposing some of your scripts into a function fname(){} form instead of keeping the approach you have used, and weighing up if this is a bad idea or not.

> Could you explain why you've gone with the approach of var x = function() as opposed to function fname(){}?

(eg. Is there a core engine script that I haven't noticed in the src folders and these var functions are api into those?)

Cheers

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)

Hi,

This is to make sure that all functions are globally accessible.
We will be rewriting our core components with ES6 standards and we will revise this as well.
At the moment we keep it simple and make all functions in the global scope.

Regards.

ohhhhh that's actually pretty freaking cool now that I understand.

There are definitely some functions I'd like to make (or keep) global, especially as I'm finessing some of your scripts to be dynamic. For example, I'm using uri location to update the page and variables to ensure I only need 1 version of the dataTable API for all my tables, instead of 10 copies of table function for 10 different tables.

Nice nice nice.. noice.

Best if you keep these scripts global so I can pick and choose, easy to convert later, and helps with test-break-learning on your black box.

Thanks happy

Yea happy. You are right. If we can help with anything else please let us know.

Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(