Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS-Best-Practive #7

Open
sntakirutimana72 opened this issue Jun 6, 2022 · 0 comments
Open

JS-Best-Practive #7

sntakirutimana72 opened this issue Jun 6, 2022 · 0 comments

Comments

@sntakirutimana72
Copy link
Owner

sntakirutimana72 commented Jun 6, 2022

Feedback

  • Some of the functions can be renamed to reflect the exact nature of their roles instead of create(), it could be createNewTask(). For instance, the code snippet below can be improved in the way mentioned above
  export const remove = (obj) => {
    let index = 0;
  • Method chaining where classes are concerned should be considered. For instance,
  class TasksManager {    
    set tasks(tasks) {
      this.allTasks = tasks;
    }
  
    assign(task) {
      this.allTasks.push(task);
    }
  • In the below code snippet, the function could've been separated into 2 functions to avoid the use of flags
  const $select = (selector, all, parentTree) => {
    parentTree = document.body;
  
    if (!parentTree) parentTree = document.body;
  
    if (all === true) return parentTree.querySelectorAll(selector);
  
    return parentTree.querySelector(selector);
  };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant