How to Open a Curly Bracket in JavaScript

JavaScript uses curly brackets to define functions and conditional statements. You must use an opening bracket to start the function or conditional statement, then close the statements with a closing curly bracket. When you have a basic JavaScript syntax understanding, you avoid frustrations with basic syntax errors and troubleshooting problems with your website code.

Instructions

    • 1

      Right-click the HTML form you want to use to run JavaScript. Click "Open With," then click the HTML editor you use to create your HTML forms.

    • 2

      Add the following code between the <head> and </head> tags to designate a section for your JavaScript code:

      <script type="text/javascript">
      </script>

    • 3

      Create your JavaScript function and use the open curly brackets to designate the start of the function. The following code shows you how to define your function:

      function name() {
      }

      The first bracket is the open curly brackets. The character is required to start a JavaScript function. The second bracket is the closing character. This curly bracket is required to end the function. Without these two characters, your JavaScript returns syntax errors.

Related Searches:

References

Comments

Related Ads

Featured