JavaScript Feature Reference: Parameter Default Value Web Browser Support Test

Last reviewed/updated: 06 Mar 2018 | Published: 21 Nov 2017 | Status: Active
Web browser support: Internet Explorer 10+, Edge 12+, Firefox 6+, Chrome 30+, Opera 17+

1. Introduction

In this web page there are two web browser JavaScript feature support tests; 1.) a feature implementation test, and 2.) a feature capability test. First, the implementation test is run. The implementation test determines if the web browser recognizes the JavaScript parameter default value. The implementation test is a simple test for the presence of web browser support, and a definitive test for the absence of web browser support. If the web browser does not recognize the JavaScript parameter default value, the testing is stopped and the implementation test reports: Fail (no support): The web browser does not recognize the JavaScript parameter default value. The web browser does not support the JavaScript parameter default value.

If the web browser recognizes the JavaScript parameter default value, the capability test is run. The capability test determines if the web browser's implementation of the JavaScript parameter default value includes support for at least one parameter default value capability. The capability test is a more definitive, albeit not an all inclusive, test for the presence of web browser support. If the web browser's implementation of the JavaScript parameter default value includes support for the tested capability, the capability test reports: Pass (at least partial/possibly full support): The web browser recognizes the JavaScript parameter default value, and supports at least one parameter default value capability. The web browser at least partially/possibly fully supports the JavaScript parameter default value. Positive determination of full web browser support is beyond the scope of this test. If the web browser's implementation of the JavaScript parameter default value does not include support for the tested capability, the capability test reports: Pass/Fail (partial support): The web browser recognizes the JavaScript parameter default value, but does not support at least one parameter default value capability. The web browser partially supports the JavaScript parameter default value.

The web browser support test source code is shown in Section 2.1. The web browser support test source code is run in Section 2.2, which shows the web browser support test result.

1.1. Parameter Default Value Web Browser Support

  • Pass (at least partial/possibly full support): ED14+, FF15+, CH49+, OP36+.
  • Fail (no support): IE11-, SF5.1.7-.

1.2. Abbreviations

  • IE = Internet Explorer.
  • ED = Edge = EdgeHTML rendering engine (ED12+) and/or Edge browser (ED20+).
  • FF = Firefox.
  • SF = Safari.
  • CH = Chrome.
  • OP = Opera.

2. Parameter Default Value Web Browser Support Test

2.1. Web Browser Support Test Source Code

<p id='testId'><b>Fail</b> (no support): The web browser does not recognize the JavaScript parameter default value. The web browser does not support the JavaScript parameter default value.</p><!-- Hard code Fail because web browser no support error stops JavaScript execution. -->

<script>
function implementationTest(param = "default value"){
 implementationTestResult = (param === "default value") ? true : false;
}
function capabilityTestOne(paramOne, paramTwo = "paramTwo default value", paramThree = "paramThree default value", paramFour = "paramFour default value"){
 capabilityTestOneResult = ((paramOne === "paramOne value") && (paramTwo === null) && (paramThree === "paramThree default value") && (paramFour === "paramFour new value")) ? true : false;
}
function capabilityTestTwo(paramOne, paramTwo = "paramTwo default value", paramThree = "paramThree default value", paramFour = "paramFour default value"){
 capabilityTestTwoResult = ((arguments.length === 3) && (arguments[0] === paramOne) && (paramOne === "paramOne value") && (arguments[1] === undefined) && (paramTwo === "paramTwo default value") && (paramTwo !== undefined) && (arguments[2] === "paramThree new value") && (paramThree === "paramThree new value") && (arguments[3] === undefined) && (arguments[3] !== paramFour) && (paramFour === "paramFour default value")) ? true : false;
}
implementationTest();
capabilityTestOne("paramOne value", null, undefined, "paramFour new value"); // "paramValueOne" passed to paramOne demonstrates traditional function argument/parameter behavior. null is valid value and is passed to paramTwo, replacing "paramTwo default value". undefined means use parameter default value. "paramFour new value" is passed to paramFour, replacing "paramFour default value".
capabilityTestTwo("paramOne value", undefined, "paramThree new value"); // Parameter default values are not set on function arguments object. Note: arguments[3] is undefined, not paramFour. Arguments passed to parameters with default values are set on function arguments object (including undefined when undefined is passed) and are set on function parameter variables (except undefined when undefined is passed).
if (implementationTestResult){
 var element = document.getElementById("testId");
 if (capabilityTestOneResult && capabilityTestTwoResult){
  element.innerHTML = "<b>Pass</b> (at least partial/possibly full support): The web browser recognizes the JavaScript parameter default value, and supports at least one parameter default value capability. The web browser at least partially/possibly fully supports the JavaScript parameter default value. Positive determination of full web browser support is beyond the scope of this test.";
 } else {
  element.innerHTML = "<b>Pass/Fail</b> (partial support): The web browser recognizes the JavaScript parameter default value, but does not support at least one parameter default value capability. The web browser partially supports the JavaScript parameter default value.";
 }
}
</script>

2.2. Web Browser Support Test Result

Fail (no support): The web browser does not recognize the JavaScript parameter default value. The web browser does not support the JavaScript parameter default value.


3. Resources And Additional Information