../blog/javascript_language

Javascript Language - Ruby Explains

  • Describe the use cases for parentheses:
    Parentheses are used to send and recieve parameters, to express something in a function or other structure. Parentheses can be used to express a null parameter - e.g. function() or contain a list of parameters - e.g. function(a, b).
  • Describe the use cases for brackets:
    Brackets are used to index arrays and strings.
    E.g. var person = {};
    person['firstname'] = 'Mario';
    person['lastname'] = 'Rossi';
  • Describe the use cases for curly brackets:
    Curly brackets can be used for defining objects, but not for defining arrays. The code inbetween the curly braces gets processed as part of that equation, but everything outside of it does not.
    E.g. var curlyBraces { };
  • Describe the use cases for single quotes and double quotes:
    Single quotes or double quotes can be used in the same way that they are used, which is to define strings. However, they can both be used in the same code for tidyness and organisation purposes.
    E.g. "He said: \"Let's go!\""
    'He said: "Let\'s go!"'
    "He said: \"Let\'s go!\""
    'He said: \"Let\'s go!\"'
>