A matter of style

Like the previous chapters, we will spend some time discussing the style considerations while creating arrays.

  • Use the literal syntax for array creation:
    // bad
    const items = new Array();
    // good
    const items = [];
  • Use Array#push instead of a direct assignment to add items to an array:
    const stack = [];
    // bad
    stack[stack.length] = 'pushme';
    // good
    stack.push('pushme');
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset