javascript function optional parameter
const myFunction = (str, id=0) => {
console.log(str, id)
}
myFunction("Hello Grepper")
// OUTPUT : "Hello Grepper 0"
myFunction("HG", 10)
// OUTPUT : "HG 10"let variableToSet = checkedValue || defaultValue;function func(arg, optArg = "defualtValue") {
console.log(arg, optArg);
}
func("A", "B"); //output "A", "B"
func("Test"); //output "Test", "defaultValue"
func(); //output undefined, "defualtValue"
Also in JavaScript:
- parse date from string in js
- onkeyup in javascript
- moment add 30 days
- import slider material ui
- get last item in map javascript
- 'userprofile/:id', ionic
- print data + js
- nuxt js lazy load page pagination
- localstorage.getitem()
- javascript array split chunk
- jquery don't empty specific form field after submit
- jquery continue in loop each
- how to get the first character of a string in javascript
- download a file nodejs
- Javascript format date / time
- add line break in innerhtml
- react mui icons
- redirect to website javascript
- integers to space separated string in javascript
- react native charts
- module not found: can't resolve 'react' in 'c:\users\pavlos\desktop\reactjs\hwr\reactproject2\src'
- d-block d-none js
- javascript event loop
- js tab in textarea