Home Set a default parameter value for a JavaScript function
Reply: 0

Set a default parameter value for a JavaScript function

user389
1#
user389 Published in June 25, 2018, 4:11 am

I would like a JavaScript function to have optional arguments which I set a default on, which gets used if the value isn't defined. In Ruby you can do it like this:

def read_file(file, delete_after = false)
  # code
end

Does this work in JavaScript?

function read_file(file, delete_after = false) {
  // Code
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.419079 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO